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 |
|---|---|---|---|---|---|---|
copygirl/WearableBackpacks | src/main/java/net/mcft/copy/backpacks/client/gui/test/GuiTestScreen.java | // Path: src/main/java/net/mcft/copy/backpacks/client/GuiTextureResource.java
// @SideOnly(Side.CLIENT)
// public class GuiTextureResource extends ResourceLocation {
//
// public final int defaultWidth;
// public final int defaultHeight;
//
// public GuiTextureResource(String location, int defaultWidth, int defaultHeight) {
// super(WearableBackpacks.MOD_ID, "textures/gui/" + location + ".png");
// this.defaultWidth = defaultWidth;
// this.defaultHeight = defaultHeight;
// }
//
// public void bind() {
// Minecraft.getMinecraft().getTextureManager().bindTexture(this);
// }
//
// /** Draws part of the texture to the screen. */
// public void drawQuad(int x, int y, int u, int v, int w, int h, float zLevel) {
// float scaleX = 1.0F / defaultWidth;
// float scaleY = 1.0F / defaultHeight;
// Tessellator tess = Tessellator.getInstance();
// BufferBuilder vb = tess.getBuffer();
// vb.begin(7, DefaultVertexFormats.POSITION_TEX);
// vb.pos(x + 0, y + h, zLevel).tex((u + 0) * scaleX, (v + h) * scaleY).endVertex();
// vb.pos(x + w, y + h, zLevel).tex((u + w) * scaleX, (v + h) * scaleY).endVertex();
// vb.pos(x + w, y + 0, zLevel).tex((u + w) * scaleX, (v + 0) * scaleY).endVertex();
// vb.pos(x + 0, y + 0, zLevel).tex((u + 0) * scaleX, (v + 0) * scaleY).endVertex();
// tess.draw();
// }
//
// /** Draws part of the texture to the screen. */
// public void drawQuad(int x, int y, int u, int v, int w, int h) {
// drawQuad(x, y, u, v, w, h, 0);
// }
//
// }
//
// Path: src/main/java/net/mcft/copy/backpacks/client/gui/control/GuiButtonIcon.java
// public static final class Icon {
// public final GuiTextureResource texture;
// public final int u, v, width, height;
//
// public Icon(GuiTextureResource texture, int u, int v, int width, int height)
// { this.texture = texture; this.u = u; this.v = v; this.width = width; this.height = height; }
// }
| import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.mcft.copy.backpacks.client.GuiTextureResource;
import net.mcft.copy.backpacks.client.gui.*;
import net.mcft.copy.backpacks.client.gui.control.*;
import net.mcft.copy.backpacks.client.gui.control.GuiButtonIcon.Icon; | setText(element.isVisible() ? "yes" : "no");
}); }});
addFixed(new GuiLabel(" Enabled: ") {{ setCenteredVertical(); }});
addWeighted(new GuiButton("yes") {{ setAction(() -> {
element.setEnabled(!element.isEnabled());
setText(element.isEnabled() ? "yes" : "no");
}); }});
}});
layout.addFixed(element);
}
}
public class ControlsScreen extends GuiContainerScreen {
public ControlsScreen() {
container.add(new GuiLayout(Direction.VERTICAL) {{
setCenteredHorizontal();
setFillVertical(8);
addFixed(new GuiSlider(Direction.HORIZONTAL) {{
setFillHorizontal();
setRange(0, 10);
setStepSize(1);
}});
addFixed(new GuiField() {{ setFillHorizontal(); }});
addFixed(new GuiScrollable() {{
setFillHorizontal();
setHeight(100);
setPadding(8); | // Path: src/main/java/net/mcft/copy/backpacks/client/GuiTextureResource.java
// @SideOnly(Side.CLIENT)
// public class GuiTextureResource extends ResourceLocation {
//
// public final int defaultWidth;
// public final int defaultHeight;
//
// public GuiTextureResource(String location, int defaultWidth, int defaultHeight) {
// super(WearableBackpacks.MOD_ID, "textures/gui/" + location + ".png");
// this.defaultWidth = defaultWidth;
// this.defaultHeight = defaultHeight;
// }
//
// public void bind() {
// Minecraft.getMinecraft().getTextureManager().bindTexture(this);
// }
//
// /** Draws part of the texture to the screen. */
// public void drawQuad(int x, int y, int u, int v, int w, int h, float zLevel) {
// float scaleX = 1.0F / defaultWidth;
// float scaleY = 1.0F / defaultHeight;
// Tessellator tess = Tessellator.getInstance();
// BufferBuilder vb = tess.getBuffer();
// vb.begin(7, DefaultVertexFormats.POSITION_TEX);
// vb.pos(x + 0, y + h, zLevel).tex((u + 0) * scaleX, (v + h) * scaleY).endVertex();
// vb.pos(x + w, y + h, zLevel).tex((u + w) * scaleX, (v + h) * scaleY).endVertex();
// vb.pos(x + w, y + 0, zLevel).tex((u + w) * scaleX, (v + 0) * scaleY).endVertex();
// vb.pos(x + 0, y + 0, zLevel).tex((u + 0) * scaleX, (v + 0) * scaleY).endVertex();
// tess.draw();
// }
//
// /** Draws part of the texture to the screen. */
// public void drawQuad(int x, int y, int u, int v, int w, int h) {
// drawQuad(x, y, u, v, w, h, 0);
// }
//
// }
//
// Path: src/main/java/net/mcft/copy/backpacks/client/gui/control/GuiButtonIcon.java
// public static final class Icon {
// public final GuiTextureResource texture;
// public final int u, v, width, height;
//
// public Icon(GuiTextureResource texture, int u, int v, int width, int height)
// { this.texture = texture; this.u = u; this.v = v; this.width = width; this.height = height; }
// }
// Path: src/main/java/net/mcft/copy/backpacks/client/gui/test/GuiTestScreen.java
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.mcft.copy.backpacks.client.GuiTextureResource;
import net.mcft.copy.backpacks.client.gui.*;
import net.mcft.copy.backpacks.client.gui.control.*;
import net.mcft.copy.backpacks.client.gui.control.GuiButtonIcon.Icon;
setText(element.isVisible() ? "yes" : "no");
}); }});
addFixed(new GuiLabel(" Enabled: ") {{ setCenteredVertical(); }});
addWeighted(new GuiButton("yes") {{ setAction(() -> {
element.setEnabled(!element.isEnabled());
setText(element.isEnabled() ? "yes" : "no");
}); }});
}});
layout.addFixed(element);
}
}
public class ControlsScreen extends GuiContainerScreen {
public ControlsScreen() {
container.add(new GuiLayout(Direction.VERTICAL) {{
setCenteredHorizontal();
setFillVertical(8);
addFixed(new GuiSlider(Direction.HORIZONTAL) {{
setFillHorizontal();
setRange(0, 10);
setStepSize(1);
}});
addFixed(new GuiField() {{ setFillHorizontal(); }});
addFixed(new GuiScrollable() {{
setFillHorizontal();
setHeight(100);
setPadding(8); | Icon icon = new Icon(new GuiTextureResource("config_icons", 64, 64), 36, 0, 8, 16); |
copygirl/WearableBackpacks | src/main/java/net/mcft/copy/backpacks/container/SlotBackpackWrapper.java | // Path: src/main/java/net/mcft/copy/backpacks/api/IBackpackType.java
// public interface IBackpackType {
//
// /** Called when an entity spawns with this backpack naturally. */
// void onSpawnedWith(EntityLivingBase entity, IBackpack capability, String lootTable);
//
// /** Called before the backpack is equipped by an entity.
// * <p>
// * Note that on the client side, there's no certainty whether
// * the backpack is actually going to be equipped successfully. */
// void onEquip(EntityLivingBase entity, TileEntity tileEntity, IBackpack backpack);
//
// /** Called after the backpack is unequipped by an entity.
// * <p>
// * Also called when the entity dies and the backpack is placed down as a block automatically,
// * which can be tested using {@link EntityLivingBase#isEntityAlive() entity.isEntityAlive()}.
// * This behavior is controlled by the "general.dropAsBlockOnDeath" config setting.
// * <p>
// * Note that on the client side, there's no certainty whether
// * the backpack is actually going to be unequipped successfully. */
// void onUnequip(EntityLivingBase entity, TileEntity tileEntity, IBackpack backpack);
//
// /** Called when a player interacts with a placed-down backpack. */
// void onPlacedInteract(EntityPlayer player, TileEntity tileEntity, IBackpack backpack);
//
// /** Called when a player interacts with an equipped backpack.
// * <p>
// * Also called when a player opens their own backpack while it's equipped,
// * which is enabled with the "general.enableSelfInteraction" config setting.
// * <p>
// * Note that the player might be a "fake" player
// * and this is also called on the client side. */
// void onEquippedInteract(EntityPlayer player, EntityLivingBase target, IBackpack backpack);
//
// /** Called every game tick when the backpack is equipped, regardless of where. */
// void onEquippedTick(EntityLivingBase entity, IBackpack backpack);
//
// /** Called before the entity wearing this backpack dies and drops the backpack item.
// * <p>
// * If either the "general.dropAsBlockOnDeath" config setting or "keepInventory"
// * gamerule are enabled, this method won't be called. */
// void onDeath(EntityLivingBase entity, IBackpack backpack);
//
// /** Called when the backpack breaks while being equipped. */
// void onEquippedBroken(EntityLivingBase entity, IBackpack backpack);
//
// /** Called when the backpack is removed from the
// * chestplate slot by means it's not supposed to. */
// void onFaultyRemoval(EntityLivingBase entity, IBackpack backpack);
//
// /** Called when this backpack is broken when placed down. */
// void onBlockBreak(TileEntity tileEntity, IBackpack backpack);
//
// /** Creates and returns a new backpack data object for this backpack. */
// IBackpackData createBackpackData(ItemStack stack);
//
//
// /** Returns the number of ticks the backpack's lid takes to fully open. */
// default int getLidMaxTicks() { return 5; }
//
// /** Returns the lid angle, from current ticks the backpack is open.
// * Used for rendering the backpack model with an animated lid. */
// default float getLidAngle(int lidTicks, int prevLidTicks, float partialTicks) {
// float progress = lidTicks + (lidTicks - prevLidTicks) * partialTicks;
// progress = Math.max(0, Math.min(getLidMaxTicks(), progress)) / getLidMaxTicks();
// return (1.0F - (float)Math.pow(1.0F - progress, 2)) * 45;
// }
//
// }
| import javax.annotation.Nullable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.mcft.copy.backpacks.api.IBackpackType; | package net.mcft.copy.backpacks.container;
/** Wraps around the regular player armor slot to
* prevent equipped backpacks from being taken out. */
public class SlotBackpackWrapper extends Slot {
public final Slot base;
public SlotBackpackWrapper(Slot base) {
super(base.inventory, base.getSlotIndex(), base.xPos, base.yPos);
this.base = base;
}
/** When a backpack is equipped, go through the currently open container, see if
* any slot contains the player's equipped backpack. If so, replace that slot with
* a wrapper that prevents the backpack from being unequipped though normal means. */
public static void replace(EntityPlayer player, ItemStack backpack) {
Container container = player.openContainer;
if (container == null) return;
for (Slot slot : container.inventorySlots) {
if (slot.getStack() != backpack) continue;
if (slot instanceof SlotBackpackWrapper) continue;
Slot newSlot = new SlotBackpackWrapper(slot);
newSlot.slotNumber = slot.slotNumber;
container.inventorySlots.set(slot.slotNumber, newSlot);
// Keep going, there may be more slots to fix!
}
}
@Override
public boolean canTakeStack(EntityPlayer player) {
return base.canTakeStack(player) | // Path: src/main/java/net/mcft/copy/backpacks/api/IBackpackType.java
// public interface IBackpackType {
//
// /** Called when an entity spawns with this backpack naturally. */
// void onSpawnedWith(EntityLivingBase entity, IBackpack capability, String lootTable);
//
// /** Called before the backpack is equipped by an entity.
// * <p>
// * Note that on the client side, there's no certainty whether
// * the backpack is actually going to be equipped successfully. */
// void onEquip(EntityLivingBase entity, TileEntity tileEntity, IBackpack backpack);
//
// /** Called after the backpack is unequipped by an entity.
// * <p>
// * Also called when the entity dies and the backpack is placed down as a block automatically,
// * which can be tested using {@link EntityLivingBase#isEntityAlive() entity.isEntityAlive()}.
// * This behavior is controlled by the "general.dropAsBlockOnDeath" config setting.
// * <p>
// * Note that on the client side, there's no certainty whether
// * the backpack is actually going to be unequipped successfully. */
// void onUnequip(EntityLivingBase entity, TileEntity tileEntity, IBackpack backpack);
//
// /** Called when a player interacts with a placed-down backpack. */
// void onPlacedInteract(EntityPlayer player, TileEntity tileEntity, IBackpack backpack);
//
// /** Called when a player interacts with an equipped backpack.
// * <p>
// * Also called when a player opens their own backpack while it's equipped,
// * which is enabled with the "general.enableSelfInteraction" config setting.
// * <p>
// * Note that the player might be a "fake" player
// * and this is also called on the client side. */
// void onEquippedInteract(EntityPlayer player, EntityLivingBase target, IBackpack backpack);
//
// /** Called every game tick when the backpack is equipped, regardless of where. */
// void onEquippedTick(EntityLivingBase entity, IBackpack backpack);
//
// /** Called before the entity wearing this backpack dies and drops the backpack item.
// * <p>
// * If either the "general.dropAsBlockOnDeath" config setting or "keepInventory"
// * gamerule are enabled, this method won't be called. */
// void onDeath(EntityLivingBase entity, IBackpack backpack);
//
// /** Called when the backpack breaks while being equipped. */
// void onEquippedBroken(EntityLivingBase entity, IBackpack backpack);
//
// /** Called when the backpack is removed from the
// * chestplate slot by means it's not supposed to. */
// void onFaultyRemoval(EntityLivingBase entity, IBackpack backpack);
//
// /** Called when this backpack is broken when placed down. */
// void onBlockBreak(TileEntity tileEntity, IBackpack backpack);
//
// /** Creates and returns a new backpack data object for this backpack. */
// IBackpackData createBackpackData(ItemStack stack);
//
//
// /** Returns the number of ticks the backpack's lid takes to fully open. */
// default int getLidMaxTicks() { return 5; }
//
// /** Returns the lid angle, from current ticks the backpack is open.
// * Used for rendering the backpack model with an animated lid. */
// default float getLidAngle(int lidTicks, int prevLidTicks, float partialTicks) {
// float progress = lidTicks + (lidTicks - prevLidTicks) * partialTicks;
// progress = Math.max(0, Math.min(getLidMaxTicks(), progress)) / getLidMaxTicks();
// return (1.0F - (float)Math.pow(1.0F - progress, 2)) * 45;
// }
//
// }
// Path: src/main/java/net/mcft/copy/backpacks/container/SlotBackpackWrapper.java
import javax.annotation.Nullable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.mcft.copy.backpacks.api.IBackpackType;
package net.mcft.copy.backpacks.container;
/** Wraps around the regular player armor slot to
* prevent equipped backpacks from being taken out. */
public class SlotBackpackWrapper extends Slot {
public final Slot base;
public SlotBackpackWrapper(Slot base) {
super(base.inventory, base.getSlotIndex(), base.xPos, base.yPos);
this.base = base;
}
/** When a backpack is equipped, go through the currently open container, see if
* any slot contains the player's equipped backpack. If so, replace that slot with
* a wrapper that prevents the backpack from being unequipped though normal means. */
public static void replace(EntityPlayer player, ItemStack backpack) {
Container container = player.openContainer;
if (container == null) return;
for (Slot slot : container.inventorySlots) {
if (slot.getStack() != backpack) continue;
if (slot instanceof SlotBackpackWrapper) continue;
Slot newSlot = new SlotBackpackWrapper(slot);
newSlot.slotNumber = slot.slotNumber;
container.inventorySlots.set(slot.slotNumber, newSlot);
// Keep going, there may be more slots to fix!
}
}
@Override
public boolean canTakeStack(EntityPlayer player) {
return base.canTakeStack(player) | && !(getStack().getItem() instanceof IBackpackType); |
copygirl/WearableBackpacks | src/main/java/net/mcft/copy/backpacks/misc/util/LangUtils.java | // Path: src/main/java/net/mcft/copy/backpacks/WearableBackpacks.java
// @Mod(modid = WearableBackpacks.MOD_ID, name = WearableBackpacks.MOD_NAME,
// version = WearableBackpacks.VERSION, dependencies = "required-after:forge@[14.21.0.2375,)",
// guiFactory = "net.mcft.copy.backpacks.client.BackpacksGuiFactory")
// public class WearableBackpacks {
//
// public static final String MOD_ID = "wearablebackpacks";
// public static final String MOD_NAME = "Wearable Backpacks";
// public static final String VERSION = "@VERSION@";
//
// @Instance
// public static WearableBackpacks INSTANCE;
//
// @SidedProxy(serverSide = "net.mcft.copy.backpacks.ProxyCommon",
// clientSide = "net.mcft.copy.backpacks.ProxyClient")
// public static ProxyCommon PROXY;
//
// public static Logger LOG;
// public static BackpacksChannel CHANNEL;
// public static BackpacksConfig CONFIG;
// public static BackpacksContent CONTENT;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// LOG = event.getModLog();
// CHANNEL = new BackpacksChannel();
//
// CONFIG = new BackpacksConfig(event.getSuggestedConfigurationFile());
// CONFIG.load();
// CONFIG.save();
//
// CONTENT = new BackpacksContent();
// CONTENT.registerRecipes();
//
// PROXY.preInit();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// CONFIG.init();
// PROXY.init();
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import org.lwjgl.input.Keyboard;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.mcft.copy.backpacks.WearableBackpacks; | package net.mcft.copy.backpacks.misc.util;
/** Contains utility methods related to language files / localization. */
public final class LangUtils {
private LangUtils() { }
/** Formats a language key and returns it as a list. */
@SideOnly(Side.CLIENT)
public static List<String> format(String langKey, Object... args)
{ return formatPrepend("", langKey, args); }
/** Formats a language key and adds it to the specified
* list, prepending each line with the specified string. */
@SideOnly(Side.CLIENT)
public static void format(List<String> list, String langKey, Object... args)
{ formatPrepend(list, "", langKey, args); }
/** Formats a language key and returns it as a list. */
@SideOnly(Side.CLIENT)
public static List<String> formatPrepend(String prepend, String langKey, Object... args) {
ArrayList<String> list = new ArrayList<String>();
formatPrepend(list, prepend, langKey, args);
return list;
}
/** Formats a language key and adds it to the specified
* list, prepending each line with the specified string. */
@SideOnly(Side.CLIENT)
public static void formatPrepend(List<String> list, String prepend, String langKey, Object... args) {
String translated = I18n.format(langKey, args);
for (String line : translated.split("\\\\n"))
list.add(prepend + line);
}
/** Formats a tooltip translation key (<code> "tooltip.modid.key" </code>)
* and adds it to the tooltip list. Used in {@link Item#addInformation}. */
@SideOnly(Side.CLIENT)
public static void formatTooltip(List<String> tooltip, String tooltipKey, Object... args) | // Path: src/main/java/net/mcft/copy/backpacks/WearableBackpacks.java
// @Mod(modid = WearableBackpacks.MOD_ID, name = WearableBackpacks.MOD_NAME,
// version = WearableBackpacks.VERSION, dependencies = "required-after:forge@[14.21.0.2375,)",
// guiFactory = "net.mcft.copy.backpacks.client.BackpacksGuiFactory")
// public class WearableBackpacks {
//
// public static final String MOD_ID = "wearablebackpacks";
// public static final String MOD_NAME = "Wearable Backpacks";
// public static final String VERSION = "@VERSION@";
//
// @Instance
// public static WearableBackpacks INSTANCE;
//
// @SidedProxy(serverSide = "net.mcft.copy.backpacks.ProxyCommon",
// clientSide = "net.mcft.copy.backpacks.ProxyClient")
// public static ProxyCommon PROXY;
//
// public static Logger LOG;
// public static BackpacksChannel CHANNEL;
// public static BackpacksConfig CONFIG;
// public static BackpacksContent CONTENT;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// LOG = event.getModLog();
// CHANNEL = new BackpacksChannel();
//
// CONFIG = new BackpacksConfig(event.getSuggestedConfigurationFile());
// CONFIG.load();
// CONFIG.save();
//
// CONTENT = new BackpacksContent();
// CONTENT.registerRecipes();
//
// PROXY.preInit();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// CONFIG.init();
// PROXY.init();
// }
//
// }
// Path: src/main/java/net/mcft/copy/backpacks/misc/util/LangUtils.java
import java.util.ArrayList;
import java.util.List;
import org.lwjgl.input.Keyboard;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.mcft.copy.backpacks.WearableBackpacks;
package net.mcft.copy.backpacks.misc.util;
/** Contains utility methods related to language files / localization. */
public final class LangUtils {
private LangUtils() { }
/** Formats a language key and returns it as a list. */
@SideOnly(Side.CLIENT)
public static List<String> format(String langKey, Object... args)
{ return formatPrepend("", langKey, args); }
/** Formats a language key and adds it to the specified
* list, prepending each line with the specified string. */
@SideOnly(Side.CLIENT)
public static void format(List<String> list, String langKey, Object... args)
{ formatPrepend(list, "", langKey, args); }
/** Formats a language key and returns it as a list. */
@SideOnly(Side.CLIENT)
public static List<String> formatPrepend(String prepend, String langKey, Object... args) {
ArrayList<String> list = new ArrayList<String>();
formatPrepend(list, prepend, langKey, args);
return list;
}
/** Formats a language key and adds it to the specified
* list, prepending each line with the specified string. */
@SideOnly(Side.CLIENT)
public static void formatPrepend(List<String> list, String prepend, String langKey, Object... args) {
String translated = I18n.format(langKey, args);
for (String line : translated.split("\\\\n"))
list.add(prepend + line);
}
/** Formats a tooltip translation key (<code> "tooltip.modid.key" </code>)
* and adds it to the tooltip list. Used in {@link Item#addInformation}. */
@SideOnly(Side.CLIENT)
public static void formatTooltip(List<String> tooltip, String tooltipKey, Object... args) | { format(tooltip, "tooltip." + WearableBackpacks.MOD_ID + "." + tooltipKey, args); } |
copygirl/WearableBackpacks | src/main/java/net/mcft/copy/backpacks/client/BackpacksGuiFactory.java | // Path: src/main/java/net/mcft/copy/backpacks/client/gui/config/BackpacksConfigScreen.java
// @SideOnly(Side.CLIENT)
// public class BackpacksConfigScreen extends BaseConfigScreen {
//
// private final GuiButton _buttonTest;
//
// /** Creates a config GUI screen for Wearable Backpacks (and its GENERAL category). */
// public BackpacksConfigScreen(GuiScreen parentScreen) {
// this(parentScreen, (String)null);
//
// // Add all settings from the GENERAL category to the entry list.
// for (Setting<?> setting : WearableBackpacks.CONFIG.getSettingsGeneral())
// addEntry(CreateEntryFromSetting(setting));
//
// // After adding all settings from the GENERAL category, add its sub-categories.
// for (String cat : WearableBackpacks.CONFIG.getCategories())
// addEntry(new EntryCategory(this, cat));
// }
//
// /** Creates a config GUI screen for a sub-category. */
// public BackpacksConfigScreen(GuiScreen parentScreen, EntryCategory category) {
// this(parentScreen, category.getLanguageKey());
//
// // Add all settings for this category to the entry list.
// for (Setting<?> setting : WearableBackpacks.CONFIG.getSettings(category.category))
// addEntry(CreateEntryFromSetting(setting));
// }
//
// public BackpacksConfigScreen(GuiScreen parentScreen, String subtitle) {
// super(parentScreen, WearableBackpacks.MOD_NAME, subtitle);
//
// _buttonTest = new GuiButton(18, 18, "T");
// _buttonTest.setRight(3);
// _buttonTest.setTop(3);
// _buttonTest.setAction(() -> GuiElementBase.display(new GuiTestScreen(BackpacksConfigScreen.this)));
// container.add(_buttonTest);
//
// // Buttons
// layoutButtons.addFixed(buttonDone);
// layoutButtons.addFixed(buttonUndo);
// layoutButtons.addFixed(buttonReset);
// }
//
//
// @SuppressWarnings("unchecked")
// public static <T> GuiElementBase CreateEntryFromSetting(Setting<T> setting) {
// String entryClassName = setting.getConfigEntryClass();
// if (entryClassName == null) throw new RuntimeException(
// "Setting '" + setting.getFullName() + "' has no entry class defined");
// try {
// Class<?> entryClass = Class.forName(entryClassName);
// if (!GuiElementBase.class.isAssignableFrom(entryClass))
// throw new Exception("Not a subclass of GuiElementBase");
//
// // If entry class is IConfigValue, create an EntrySetting using it.
// if (IConfigValue.class.isAssignableFrom(entryClass))
// return new EntrySetting<T>(setting, (IConfigValue<T>)entryClass.newInstance());
//
// // Find a constructor that has exactly one parameter of a compatible setting type.
// Constructor<?> constructor = Arrays.stream(entryClass.getConstructors())
// .filter(c -> (c.getParameterCount() == 1) && c.getParameterTypes()[0].isAssignableFrom(setting.getClass()))
// .findFirst().orElseThrow(() -> new Exception("No compatible constructor found"));
// // Create and return a new instance of this entry class.
// return (GuiElementBase)constructor.newInstance(setting);
// } catch (Exception ex) { throw new RuntimeException(
// "Exception while instanciating setting entry for '" +
// setting.getFullName() + "' (entry class '" + entryClassName + "')", ex); }
// }
//
//
// @Override
// protected void doneClicked() {
// GuiScreen nextScreen = parentScreen;
// // If this is the root config screen, apply the changes!
// if (!(parentScreen instanceof BackpacksConfigScreen)) {
// if (applyChanges() == ChangeRequiredAction.RestartMinecraft)
// nextScreen = new GuiMessageDialog(parentScreen,
// "fml.configgui.gameRestartTitle",
// new TextComponentString(I18n.format("fml.configgui.gameRestartRequired")),
// "fml.configgui.confirmRestartMessage");
// WearableBackpacks.CONFIG.save();
// }
// GuiElementBase.display(nextScreen);
// }
//
//
// @Override
// public void drawScreen(int mouseX, int mouseY, float partialTicks) {
// _buttonTest.setVisible(GuiContext.DEBUG);
// buttonDone.setEnabled(isValid());
// buttonUndo.setEnabled(isChanged());
// buttonReset.setEnabled(!isDefault());
// super.drawScreen(mouseX, mouseY, partialTicks);
// }
//
// }
| import java.util.Set;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.fml.client.IModGuiFactory;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.mcft.copy.backpacks.client.gui.config.BackpacksConfigScreen; | package net.mcft.copy.backpacks.client;
@SideOnly(Side.CLIENT)
public class BackpacksGuiFactory implements IModGuiFactory {
@Override
public void initialize(Minecraft minecraftInstance) { }
@Override
public boolean hasConfigGui() { return true; }
@Override | // Path: src/main/java/net/mcft/copy/backpacks/client/gui/config/BackpacksConfigScreen.java
// @SideOnly(Side.CLIENT)
// public class BackpacksConfigScreen extends BaseConfigScreen {
//
// private final GuiButton _buttonTest;
//
// /** Creates a config GUI screen for Wearable Backpacks (and its GENERAL category). */
// public BackpacksConfigScreen(GuiScreen parentScreen) {
// this(parentScreen, (String)null);
//
// // Add all settings from the GENERAL category to the entry list.
// for (Setting<?> setting : WearableBackpacks.CONFIG.getSettingsGeneral())
// addEntry(CreateEntryFromSetting(setting));
//
// // After adding all settings from the GENERAL category, add its sub-categories.
// for (String cat : WearableBackpacks.CONFIG.getCategories())
// addEntry(new EntryCategory(this, cat));
// }
//
// /** Creates a config GUI screen for a sub-category. */
// public BackpacksConfigScreen(GuiScreen parentScreen, EntryCategory category) {
// this(parentScreen, category.getLanguageKey());
//
// // Add all settings for this category to the entry list.
// for (Setting<?> setting : WearableBackpacks.CONFIG.getSettings(category.category))
// addEntry(CreateEntryFromSetting(setting));
// }
//
// public BackpacksConfigScreen(GuiScreen parentScreen, String subtitle) {
// super(parentScreen, WearableBackpacks.MOD_NAME, subtitle);
//
// _buttonTest = new GuiButton(18, 18, "T");
// _buttonTest.setRight(3);
// _buttonTest.setTop(3);
// _buttonTest.setAction(() -> GuiElementBase.display(new GuiTestScreen(BackpacksConfigScreen.this)));
// container.add(_buttonTest);
//
// // Buttons
// layoutButtons.addFixed(buttonDone);
// layoutButtons.addFixed(buttonUndo);
// layoutButtons.addFixed(buttonReset);
// }
//
//
// @SuppressWarnings("unchecked")
// public static <T> GuiElementBase CreateEntryFromSetting(Setting<T> setting) {
// String entryClassName = setting.getConfigEntryClass();
// if (entryClassName == null) throw new RuntimeException(
// "Setting '" + setting.getFullName() + "' has no entry class defined");
// try {
// Class<?> entryClass = Class.forName(entryClassName);
// if (!GuiElementBase.class.isAssignableFrom(entryClass))
// throw new Exception("Not a subclass of GuiElementBase");
//
// // If entry class is IConfigValue, create an EntrySetting using it.
// if (IConfigValue.class.isAssignableFrom(entryClass))
// return new EntrySetting<T>(setting, (IConfigValue<T>)entryClass.newInstance());
//
// // Find a constructor that has exactly one parameter of a compatible setting type.
// Constructor<?> constructor = Arrays.stream(entryClass.getConstructors())
// .filter(c -> (c.getParameterCount() == 1) && c.getParameterTypes()[0].isAssignableFrom(setting.getClass()))
// .findFirst().orElseThrow(() -> new Exception("No compatible constructor found"));
// // Create and return a new instance of this entry class.
// return (GuiElementBase)constructor.newInstance(setting);
// } catch (Exception ex) { throw new RuntimeException(
// "Exception while instanciating setting entry for '" +
// setting.getFullName() + "' (entry class '" + entryClassName + "')", ex); }
// }
//
//
// @Override
// protected void doneClicked() {
// GuiScreen nextScreen = parentScreen;
// // If this is the root config screen, apply the changes!
// if (!(parentScreen instanceof BackpacksConfigScreen)) {
// if (applyChanges() == ChangeRequiredAction.RestartMinecraft)
// nextScreen = new GuiMessageDialog(parentScreen,
// "fml.configgui.gameRestartTitle",
// new TextComponentString(I18n.format("fml.configgui.gameRestartRequired")),
// "fml.configgui.confirmRestartMessage");
// WearableBackpacks.CONFIG.save();
// }
// GuiElementBase.display(nextScreen);
// }
//
//
// @Override
// public void drawScreen(int mouseX, int mouseY, float partialTicks) {
// _buttonTest.setVisible(GuiContext.DEBUG);
// buttonDone.setEnabled(isValid());
// buttonUndo.setEnabled(isChanged());
// buttonReset.setEnabled(!isDefault());
// super.drawScreen(mouseX, mouseY, partialTicks);
// }
//
// }
// Path: src/main/java/net/mcft/copy/backpacks/client/BackpacksGuiFactory.java
import java.util.Set;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.fml.client.IModGuiFactory;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.mcft.copy.backpacks.client.gui.config.BackpacksConfigScreen;
package net.mcft.copy.backpacks.client;
@SideOnly(Side.CLIENT)
public class BackpacksGuiFactory implements IModGuiFactory {
@Override
public void initialize(Minecraft minecraftInstance) { }
@Override
public boolean hasConfigGui() { return true; }
@Override | public GuiScreen createConfigGui(GuiScreen parentScreen) { return new BackpacksConfigScreen(parentScreen); } |
copygirl/WearableBackpacks | src/main/java/net/mcft/copy/backpacks/client/gui/control/GuiButtonIcon.java | // Path: src/main/java/net/mcft/copy/backpacks/client/GuiTextureResource.java
// @SideOnly(Side.CLIENT)
// public class GuiTextureResource extends ResourceLocation {
//
// public final int defaultWidth;
// public final int defaultHeight;
//
// public GuiTextureResource(String location, int defaultWidth, int defaultHeight) {
// super(WearableBackpacks.MOD_ID, "textures/gui/" + location + ".png");
// this.defaultWidth = defaultWidth;
// this.defaultHeight = defaultHeight;
// }
//
// public void bind() {
// Minecraft.getMinecraft().getTextureManager().bindTexture(this);
// }
//
// /** Draws part of the texture to the screen. */
// public void drawQuad(int x, int y, int u, int v, int w, int h, float zLevel) {
// float scaleX = 1.0F / defaultWidth;
// float scaleY = 1.0F / defaultHeight;
// Tessellator tess = Tessellator.getInstance();
// BufferBuilder vb = tess.getBuffer();
// vb.begin(7, DefaultVertexFormats.POSITION_TEX);
// vb.pos(x + 0, y + h, zLevel).tex((u + 0) * scaleX, (v + h) * scaleY).endVertex();
// vb.pos(x + w, y + h, zLevel).tex((u + w) * scaleX, (v + h) * scaleY).endVertex();
// vb.pos(x + w, y + 0, zLevel).tex((u + w) * scaleX, (v + 0) * scaleY).endVertex();
// vb.pos(x + 0, y + 0, zLevel).tex((u + 0) * scaleX, (v + 0) * scaleY).endVertex();
// tess.draw();
// }
//
// /** Draws part of the texture to the screen. */
// public void drawQuad(int x, int y, int u, int v, int w, int h) {
// drawQuad(x, y, u, v, w, h, 0);
// }
//
// }
| import net.minecraft.client.gui.FontRenderer;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.mcft.copy.backpacks.client.GuiTextureResource; |
@Override
protected void drawButtonForeground(boolean isHighlighted, float partialTicks) {
String text = getText();
FontRenderer fontRenderer = getFontRenderer();
int contentWidth = _icon.width;
if (!text.isEmpty()) {
int textWidth = fontRenderer.getStringWidth(text);
int maxTextWidth = getWidth() - _icon.width - ICON_SPACING - MIN_TEXT_PADDING;
if ((textWidth > maxTextWidth) && (textWidth > ELLIPSIS_WIDTH)) {
text = fontRenderer.trimStringToWidth(text, maxTextWidth - ELLIPSIS_WIDTH).trim() + ELLIPSIS;
textWidth = fontRenderer.getStringWidth(text);
}
contentWidth += ICON_SPACING + textWidth;
}
int x = (getWidth() - contentWidth) / 2;
int y = (getHeight() - _icon.height) / 2;
_icon.texture.bind();
_icon.texture.drawQuad(x, y, _icon.u, _icon.v, _icon.width, _icon.height);
if (!text.isEmpty())
fontRenderer.drawStringWithShadow(text,
x + _icon.width + ICON_SPACING,
(getHeight() - 8) / 2, getTextColor(isHighlighted));
}
public static final class Icon { | // Path: src/main/java/net/mcft/copy/backpacks/client/GuiTextureResource.java
// @SideOnly(Side.CLIENT)
// public class GuiTextureResource extends ResourceLocation {
//
// public final int defaultWidth;
// public final int defaultHeight;
//
// public GuiTextureResource(String location, int defaultWidth, int defaultHeight) {
// super(WearableBackpacks.MOD_ID, "textures/gui/" + location + ".png");
// this.defaultWidth = defaultWidth;
// this.defaultHeight = defaultHeight;
// }
//
// public void bind() {
// Minecraft.getMinecraft().getTextureManager().bindTexture(this);
// }
//
// /** Draws part of the texture to the screen. */
// public void drawQuad(int x, int y, int u, int v, int w, int h, float zLevel) {
// float scaleX = 1.0F / defaultWidth;
// float scaleY = 1.0F / defaultHeight;
// Tessellator tess = Tessellator.getInstance();
// BufferBuilder vb = tess.getBuffer();
// vb.begin(7, DefaultVertexFormats.POSITION_TEX);
// vb.pos(x + 0, y + h, zLevel).tex((u + 0) * scaleX, (v + h) * scaleY).endVertex();
// vb.pos(x + w, y + h, zLevel).tex((u + w) * scaleX, (v + h) * scaleY).endVertex();
// vb.pos(x + w, y + 0, zLevel).tex((u + w) * scaleX, (v + 0) * scaleY).endVertex();
// vb.pos(x + 0, y + 0, zLevel).tex((u + 0) * scaleX, (v + 0) * scaleY).endVertex();
// tess.draw();
// }
//
// /** Draws part of the texture to the screen. */
// public void drawQuad(int x, int y, int u, int v, int w, int h) {
// drawQuad(x, y, u, v, w, h, 0);
// }
//
// }
// Path: src/main/java/net/mcft/copy/backpacks/client/gui/control/GuiButtonIcon.java
import net.minecraft.client.gui.FontRenderer;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.mcft.copy.backpacks.client.GuiTextureResource;
@Override
protected void drawButtonForeground(boolean isHighlighted, float partialTicks) {
String text = getText();
FontRenderer fontRenderer = getFontRenderer();
int contentWidth = _icon.width;
if (!text.isEmpty()) {
int textWidth = fontRenderer.getStringWidth(text);
int maxTextWidth = getWidth() - _icon.width - ICON_SPACING - MIN_TEXT_PADDING;
if ((textWidth > maxTextWidth) && (textWidth > ELLIPSIS_WIDTH)) {
text = fontRenderer.trimStringToWidth(text, maxTextWidth - ELLIPSIS_WIDTH).trim() + ELLIPSIS;
textWidth = fontRenderer.getStringWidth(text);
}
contentWidth += ICON_SPACING + textWidth;
}
int x = (getWidth() - contentWidth) / 2;
int y = (getHeight() - _icon.height) / 2;
_icon.texture.bind();
_icon.texture.drawQuad(x, y, _icon.u, _icon.v, _icon.width, _icon.height);
if (!text.isEmpty())
fontRenderer.drawStringWithShadow(text,
x + _icon.width + ICON_SPACING,
(getHeight() - 8) / 2, getTextColor(isHighlighted));
}
public static final class Icon { | public final GuiTextureResource texture; |
copygirl/WearableBackpacks | src/main/java/net/mcft/copy/backpacks/client/gui/GuiContainerScreen.java | // Path: src/main/java/net/mcft/copy/backpacks/client/gui/GuiElementBase.java
// public static final class MouseButton {
// private MouseButton() { }
//
// public static int LEFT = 0;
// public static int RIGHT = 1;
// public static int MIDDLE = 2;
// }
| import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.mcft.copy.backpacks.client.gui.GuiElementBase.MouseButton; | package net.mcft.copy.backpacks.client.gui;
@SideOnly(Side.CLIENT)
public class GuiContainerScreen extends GuiScreen {
private int _lastMouseX = -1;
private int _lastMouseY = -1;
public final GuiContext context;
public final GuiContainer container;
private GuiElementBase _tooltipElement = null;
private long _tooltipTime = 0;
public GuiContainerScreen() {
context = new GuiContext();
container = new GuiContainer(context);
container.setFill();
}
@Override
public void setWorldAndResolution(Minecraft mc, int width, int height) {
context.setScreen(this);
super.setWorldAndResolution(mc, width, height);
container.setSize(width, height);
}
@Override
public void onGuiClosed() { context.setScreen(null); }
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) { | // Path: src/main/java/net/mcft/copy/backpacks/client/gui/GuiElementBase.java
// public static final class MouseButton {
// private MouseButton() { }
//
// public static int LEFT = 0;
// public static int RIGHT = 1;
// public static int MIDDLE = 2;
// }
// Path: src/main/java/net/mcft/copy/backpacks/client/gui/GuiContainerScreen.java
import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.mcft.copy.backpacks.client.gui.GuiElementBase.MouseButton;
package net.mcft.copy.backpacks.client.gui;
@SideOnly(Side.CLIENT)
public class GuiContainerScreen extends GuiScreen {
private int _lastMouseX = -1;
private int _lastMouseY = -1;
public final GuiContext context;
public final GuiContainer container;
private GuiElementBase _tooltipElement = null;
private long _tooltipTime = 0;
public GuiContainerScreen() {
context = new GuiContext();
container = new GuiContainer(context);
container.setFill();
}
@Override
public void setWorldAndResolution(Minecraft mc, int width, int height) {
context.setScreen(this);
super.setWorldAndResolution(mc, width, height);
container.setSize(width, height);
}
@Override
public void onGuiClosed() { context.setScreen(null); }
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) { | if (mouseButton == MouseButton.LEFT) |
copygirl/WearableBackpacks | src/main/java/net/mcft/copy/backpacks/client/gui/config/IConfigEntry.java | // Path: src/main/java/net/mcft/copy/backpacks/config/Setting.java
// public enum ChangeRequiredAction {
// None,
// RejoinWorld,
// RestartMinecraft
// }
| import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.mcft.copy.backpacks.config.Setting.ChangeRequiredAction; | package net.mcft.copy.backpacks.client.gui.config;
@SideOnly(Side.CLIENT)
public interface IConfigEntry {
public static final int DEFAULT_ENTRY_HEIGHT = 18;
public static final String TOOLTIP_TITLE = TextFormatting.GREEN.toString();
public static final String TOOLTIP_TEXT = TextFormatting.YELLOW.toString();
public static final String TOOLTIP_DEFAULT = TextFormatting.AQUA.toString();
public static final String TOOLTIP_WARN = TextFormatting.RED.toString();
/** Returns whether this entry was changed from its previous value. */
public boolean isChanged();
/** Returns whether this entry's value is equal to its default value. */
public boolean isDefault();
/** Returns whether the control for this entry represents a valid value. */
public boolean isValid();
/** Sets this entry's value to the previous value. */
public void undoChanges();
/** Sets this enrtry's value to its default value. */
public void setToDefault();
/** Applies the changes made to this entry globally.
* Called when clicking "Done" on the main config screen. */ | // Path: src/main/java/net/mcft/copy/backpacks/config/Setting.java
// public enum ChangeRequiredAction {
// None,
// RejoinWorld,
// RestartMinecraft
// }
// Path: src/main/java/net/mcft/copy/backpacks/client/gui/config/IConfigEntry.java
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.mcft.copy.backpacks.config.Setting.ChangeRequiredAction;
package net.mcft.copy.backpacks.client.gui.config;
@SideOnly(Side.CLIENT)
public interface IConfigEntry {
public static final int DEFAULT_ENTRY_HEIGHT = 18;
public static final String TOOLTIP_TITLE = TextFormatting.GREEN.toString();
public static final String TOOLTIP_TEXT = TextFormatting.YELLOW.toString();
public static final String TOOLTIP_DEFAULT = TextFormatting.AQUA.toString();
public static final String TOOLTIP_WARN = TextFormatting.RED.toString();
/** Returns whether this entry was changed from its previous value. */
public boolean isChanged();
/** Returns whether this entry's value is equal to its default value. */
public boolean isDefault();
/** Returns whether the control for this entry represents a valid value. */
public boolean isValid();
/** Sets this entry's value to the previous value. */
public void undoChanges();
/** Sets this enrtry's value to its default value. */
public void setToDefault();
/** Applies the changes made to this entry globally.
* Called when clicking "Done" on the main config screen. */ | public ChangeRequiredAction applyChanges(); |
copygirl/WearableBackpacks | src/main/java/net/mcft/copy/backpacks/network/BackpacksMessageHandler.java | // Path: src/main/java/net/mcft/copy/backpacks/misc/util/ClientUtils.java
// public final class ClientUtils {
//
// private ClientUtils() { }
//
//
// /** Returns the local (client) player entity. Will crash if called on the server. */
// public static EntityPlayer getPlayer() { return getMC().player; }
//
// /** Returns the local (client) world. Will crash if called on the server. */
// public static World getWorld() { return getMC().world; }
//
// /** Returns the local (client) thread scheduler, which allows tasks to be
// * scheduled on the main game thread. Will crash if called on the server. */
// public static IThreadListener getScheduler() { return getMC(); }
//
//
// private static Minecraft getMC() { return Minecraft.getMinecraft(); }
//
// }
| import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.IThreadListener;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
import net.mcft.copy.backpacks.misc.util.ClientUtils; | package net.mcft.copy.backpacks.network;
public abstract class BackpacksMessageHandler<T extends IMessage> implements IMessageHandler<T, IMessage> {
/** Returns whether the message handling should be scheduled, meaning it
* will be executed on the world thread instead of the network thread. */
public boolean isScheduled() { return true; }
public abstract void handle(T message, MessageContext ctx);
// IMessageHandler implementation
@Override
public final IMessage onMessage(T message, MessageContext ctx) {
if (!isScheduled()) handle(message, ctx);
else getScheduler(ctx).addScheduledTask(() -> handle(message, ctx));
return null;
}
// Utility methods
/** Returns the player associated with this message context.
* On the server, returns the player who sent the message.
* On the client, returns the local player entity. */
public static EntityPlayer getPlayer(MessageContext ctx) | // Path: src/main/java/net/mcft/copy/backpacks/misc/util/ClientUtils.java
// public final class ClientUtils {
//
// private ClientUtils() { }
//
//
// /** Returns the local (client) player entity. Will crash if called on the server. */
// public static EntityPlayer getPlayer() { return getMC().player; }
//
// /** Returns the local (client) world. Will crash if called on the server. */
// public static World getWorld() { return getMC().world; }
//
// /** Returns the local (client) thread scheduler, which allows tasks to be
// * scheduled on the main game thread. Will crash if called on the server. */
// public static IThreadListener getScheduler() { return getMC(); }
//
//
// private static Minecraft getMC() { return Minecraft.getMinecraft(); }
//
// }
// Path: src/main/java/net/mcft/copy/backpacks/network/BackpacksMessageHandler.java
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.IThreadListener;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
import net.mcft.copy.backpacks.misc.util.ClientUtils;
package net.mcft.copy.backpacks.network;
public abstract class BackpacksMessageHandler<T extends IMessage> implements IMessageHandler<T, IMessage> {
/** Returns whether the message handling should be scheduled, meaning it
* will be executed on the world thread instead of the network thread. */
public boolean isScheduled() { return true; }
public abstract void handle(T message, MessageContext ctx);
// IMessageHandler implementation
@Override
public final IMessage onMessage(T message, MessageContext ctx) {
if (!isScheduled()) handle(message, ctx);
else getScheduler(ctx).addScheduledTask(() -> handle(message, ctx));
return null;
}
// Utility methods
/** Returns the player associated with this message context.
* On the server, returns the player who sent the message.
* On the client, returns the local player entity. */
public static EntityPlayer getPlayer(MessageContext ctx) | { return (ctx.side.isServer() ? ctx.getServerHandler().player : ClientUtils.getPlayer()); } |
copygirl/WearableBackpacks | src/main/java/net/mcft/copy/backpacks/network/BackpacksChannel.java | // Path: src/main/java/net/mcft/copy/backpacks/WearableBackpacks.java
// @Mod(modid = WearableBackpacks.MOD_ID, name = WearableBackpacks.MOD_NAME,
// version = WearableBackpacks.VERSION, dependencies = "required-after:forge@[14.21.0.2375,)",
// guiFactory = "net.mcft.copy.backpacks.client.BackpacksGuiFactory")
// public class WearableBackpacks {
//
// public static final String MOD_ID = "wearablebackpacks";
// public static final String MOD_NAME = "Wearable Backpacks";
// public static final String VERSION = "@VERSION@";
//
// @Instance
// public static WearableBackpacks INSTANCE;
//
// @SidedProxy(serverSide = "net.mcft.copy.backpacks.ProxyCommon",
// clientSide = "net.mcft.copy.backpacks.ProxyClient")
// public static ProxyCommon PROXY;
//
// public static Logger LOG;
// public static BackpacksChannel CHANNEL;
// public static BackpacksConfig CONFIG;
// public static BackpacksContent CONTENT;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// LOG = event.getModLog();
// CHANNEL = new BackpacksChannel();
//
// CONFIG = new BackpacksConfig(event.getSuggestedConfigurationFile());
// CONFIG.load();
// CONFIG.save();
//
// CONTENT = new BackpacksContent();
// CONTENT.registerRecipes();
//
// PROXY.preInit();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// CONFIG.init();
// PROXY.init();
// }
//
// }
| import java.util.List;
import java.util.function.Predicate;
import net.minecraft.world.WorldServer;
import net.minecraft.world.World;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import net.minecraftforge.fml.relauncher.Side;
import net.mcft.copy.backpacks.WearableBackpacks; | package net.mcft.copy.backpacks.network;
/** Main network class. Handles registering messages
* and sending them to clients as well as the server. */
public class BackpacksChannel extends SimpleNetworkWrapper {
public BackpacksChannel() { | // Path: src/main/java/net/mcft/copy/backpacks/WearableBackpacks.java
// @Mod(modid = WearableBackpacks.MOD_ID, name = WearableBackpacks.MOD_NAME,
// version = WearableBackpacks.VERSION, dependencies = "required-after:forge@[14.21.0.2375,)",
// guiFactory = "net.mcft.copy.backpacks.client.BackpacksGuiFactory")
// public class WearableBackpacks {
//
// public static final String MOD_ID = "wearablebackpacks";
// public static final String MOD_NAME = "Wearable Backpacks";
// public static final String VERSION = "@VERSION@";
//
// @Instance
// public static WearableBackpacks INSTANCE;
//
// @SidedProxy(serverSide = "net.mcft.copy.backpacks.ProxyCommon",
// clientSide = "net.mcft.copy.backpacks.ProxyClient")
// public static ProxyCommon PROXY;
//
// public static Logger LOG;
// public static BackpacksChannel CHANNEL;
// public static BackpacksConfig CONFIG;
// public static BackpacksContent CONTENT;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// LOG = event.getModLog();
// CHANNEL = new BackpacksChannel();
//
// CONFIG = new BackpacksConfig(event.getSuggestedConfigurationFile());
// CONFIG.load();
// CONFIG.save();
//
// CONTENT = new BackpacksContent();
// CONTENT.registerRecipes();
//
// PROXY.preInit();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// CONFIG.init();
// PROXY.init();
// }
//
// }
// Path: src/main/java/net/mcft/copy/backpacks/network/BackpacksChannel.java
import java.util.List;
import java.util.function.Predicate;
import net.minecraft.world.WorldServer;
import net.minecraft.world.World;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import net.minecraftforge.fml.relauncher.Side;
import net.mcft.copy.backpacks.WearableBackpacks;
package net.mcft.copy.backpacks.network;
/** Main network class. Handles registering messages
* and sending them to clients as well as the server. */
public class BackpacksChannel extends SimpleNetworkWrapper {
public BackpacksChannel() { | super(WearableBackpacks.MOD_ID); |
DMCApps/NavigationFragment | navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/core/FragmentManagerWrapper.java | // Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/utils/ObjectUtils.java
// public final class ObjectUtils {
// private static final String TAG = ObjectUtils.class.getSimpleName();
//
// private ObjectUtils() { }
//
// /**
// * This is a seudo method of the C# as keyword. It will check the type of obj and cast to the appropriate class if it is that type or return null it not.
// *
// * @param
// * obj -> The object to be checked with as
// * @param
// * asClass -> The class type we are checking obj against
// * @param
// * <T> -> The type of class that we anticipate returning
// * @return
// * The object casted to the given class or<br />
// * null if it's not that type of class
// */
// public static <T> T as(Class<T> asClass, Object obj) {
// return asClass.isInstance(obj) ? asClass.cast(obj) : null;
// }
// }
| import android.annotation.SuppressLint;
import android.support.annotation.NonNull;
import com.github.dmcapps.navigationfragment.common.utils.ObjectUtils; | package com.github.dmcapps.navigationfragment.common.core;
/**
* Created by dcarmo on 2016-11-19.
*/
@SuppressLint("CommitTransaction")
class FragmentManagerWrapper {
private android.app.FragmentManager fragmentManager;
private android.support.v4.app.FragmentManager supportFragmentManager;
FragmentManagerWrapper(@NonNull Object object) { | // Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/utils/ObjectUtils.java
// public final class ObjectUtils {
// private static final String TAG = ObjectUtils.class.getSimpleName();
//
// private ObjectUtils() { }
//
// /**
// * This is a seudo method of the C# as keyword. It will check the type of obj and cast to the appropriate class if it is that type or return null it not.
// *
// * @param
// * obj -> The object to be checked with as
// * @param
// * asClass -> The class type we are checking obj against
// * @param
// * <T> -> The type of class that we anticipate returning
// * @return
// * The object casted to the given class or<br />
// * null if it's not that type of class
// */
// public static <T> T as(Class<T> asClass, Object obj) {
// return asClass.isInstance(obj) ? asClass.cast(obj) : null;
// }
// }
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/core/FragmentManagerWrapper.java
import android.annotation.SuppressLint;
import android.support.annotation.NonNull;
import com.github.dmcapps.navigationfragment.common.utils.ObjectUtils;
package com.github.dmcapps.navigationfragment.common.core;
/**
* Created by dcarmo on 2016-11-19.
*/
@SuppressLint("CommitTransaction")
class FragmentManagerWrapper {
private android.app.FragmentManager fragmentManager;
private android.support.v4.app.FragmentManager supportFragmentManager;
FragmentManagerWrapper(@NonNull Object object) { | fragmentManager = ObjectUtils.as(android.app.FragmentManager.class, object); |
DMCApps/NavigationFragment | navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/core/FragmentTransactionWrapper.java | // Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/utils/ObjectUtils.java
// public final class ObjectUtils {
// private static final String TAG = ObjectUtils.class.getSimpleName();
//
// private ObjectUtils() { }
//
// /**
// * This is a seudo method of the C# as keyword. It will check the type of obj and cast to the appropriate class if it is that type or return null it not.
// *
// * @param
// * obj -> The object to be checked with as
// * @param
// * asClass -> The class type we are checking obj against
// * @param
// * <T> -> The type of class that we anticipate returning
// * @return
// * The object casted to the given class or<br />
// * null if it's not that type of class
// */
// public static <T> T as(Class<T> asClass, Object obj) {
// return asClass.isInstance(obj) ? asClass.cast(obj) : null;
// }
// }
| import android.os.Build;
import android.support.annotation.NonNull;
import android.transition.Transition;
import android.view.Gravity;
import android.view.View;
import com.github.dmcapps.navigationfragment.common.utils.ObjectUtils; | package com.github.dmcapps.navigationfragment.common.core;
/**
* Created by dcarmo on 2016-11-19.
*/
class FragmentTransactionWrapper {
private static final String TAG = FragmentTransactionWrapper.class.getSimpleName();
private android.app.FragmentTransaction fragmentTransaction;
private android.support.v4.app.FragmentTransaction supportFragmentTransaction;
FragmentTransactionWrapper(@NonNull Object object) { | // Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/utils/ObjectUtils.java
// public final class ObjectUtils {
// private static final String TAG = ObjectUtils.class.getSimpleName();
//
// private ObjectUtils() { }
//
// /**
// * This is a seudo method of the C# as keyword. It will check the type of obj and cast to the appropriate class if it is that type or return null it not.
// *
// * @param
// * obj -> The object to be checked with as
// * @param
// * asClass -> The class type we are checking obj against
// * @param
// * <T> -> The type of class that we anticipate returning
// * @return
// * The object casted to the given class or<br />
// * null if it's not that type of class
// */
// public static <T> T as(Class<T> asClass, Object obj) {
// return asClass.isInstance(obj) ? asClass.cast(obj) : null;
// }
// }
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/core/FragmentTransactionWrapper.java
import android.os.Build;
import android.support.annotation.NonNull;
import android.transition.Transition;
import android.view.Gravity;
import android.view.View;
import com.github.dmcapps.navigationfragment.common.utils.ObjectUtils;
package com.github.dmcapps.navigationfragment.common.core;
/**
* Created by dcarmo on 2016-11-19.
*/
class FragmentTransactionWrapper {
private static final String TAG = FragmentTransactionWrapper.class.getSimpleName();
private android.app.FragmentTransaction fragmentTransaction;
private android.support.v4.app.FragmentTransaction supportFragmentTransaction;
FragmentTransactionWrapper(@NonNull Object object) { | fragmentTransaction = ObjectUtils.as(android.app.FragmentTransaction.class, object); |
DMCApps/NavigationFragment | app/src/main/java/com/github/dmcapps/navigationfragmentexample/MainActivity.java | // Path: app/src/main/java/com/github/dmcapps/navigationfragmentexample/v7/SupportExamplesActivity.java
// public class SupportExamplesActivity extends ActionBarActivity implements AdapterView.OnItemClickListener {
//
// ListView mList;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_main);
//
// mList = (ListView) findViewById(android.R.id.list);
//
// ArrayList<String> items = new ArrayList<>();
// items.add("Single Stack Example");
// items.add("Tab Example");
// items.add("Navigation Drawer Example (uses replace and remove as well as non-Navigation Fragments)");
// items.add("Override Default Animations Example");
// items.add("Navigation Fragment with View Pager. Navigating on view pager tab and view pager itself (git issue 5)");
// items.add("Navigation Fragment with View Pager and SmartTabLayout. Navigating on view pager tab and view pager itself (git issue 10)");
// items.add("Navigation Fragment clears stack before presenting");
//
// mList.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, items));
// mList.setOnItemClickListener(this);
// }
//
// @Override
// public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// Intent intent = null;
//
// if (position == 0) {
// intent = new Intent(this, SingleStackNavigationExampleActivity.class);
// } else if (position == 1) {
// intent = new Intent(this, ViewPagerNavigationExampleActivity.class);
// } else if (position == 2) {
// intent = new Intent(this, NavigationDrawerExampleActivity.class);
// } else if (position == 3) {
// intent = new Intent(this, OverrideDefaultAnimationsExampleActivity.class);
// } else if (position == 4) {
// intent = new Intent(this, GitIssue5ExampleActivity.class);
// } else if (position == 5) {
// intent = new Intent(this, GitIssue10ExampleActivity.class);
// } else if (position == 6) {
// intent = new Intent(this, NavigationDrawerClearStackExampleActivity.class);
// }
//
// startActivity(intent);
// }
// }
//
// Path: app/src/main/java/com/github/dmcapps/navigationfragmentexample/v17/NonSupportExamplesActivity.java
// public class NonSupportExamplesActivity extends ActionBarActivity implements AdapterView.OnItemClickListener {
//
// ListView mList;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_main);
//
// mList = (ListView) findViewById(android.R.id.list);
//
// ArrayList<String> items = new ArrayList<>();
// items.add("Single Stack Example");
// items.add("Tab Example");
// items.add("Navigation Drawer Example (uses replace and remove as well as non-Navigation Fragments)");
// items.add("Override Default Animations Example");
// items.add("Navigation Fragment clears stack before presenting");
// items.add("Transition Example");
//
// mList.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, items));
// mList.setOnItemClickListener(this);
// }
//
// @Override
// public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// Intent intent = null;
//
// if (position == 0) {
// intent = new Intent(this, SingleStackNavigationExampleActivity.class);
// } else if (position == 1) {
// intent = new Intent(this, ViewPagerNavigationExampleActivity.class);
// } else if (position == 2) {
// intent = new Intent(this, NavigationDrawerExampleActivity.class);
// } else if (position == 3) {
// intent = new Intent(this, OverrideDefaultAnimationsExampleActivity.class);
// } else if (position == 4) {
// intent = new Intent(this, NavigationDrawerClearStackExampleActivity.class);
// } else if (position == 5) {
// intent = new Intent(this, TransitionExampleActivity.class);
// }
//
// startActivity(intent);
// }
// }
| import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import com.github.dmcapps.navigationfragmentexample.v7.SupportExamplesActivity;
import com.github.dmcapps.navigationfragmentexample.v17.NonSupportExamplesActivity;
import java.util.ArrayList; | package com.github.dmcapps.navigationfragmentexample;
public class MainActivity extends ActionBarActivity implements AdapterView.OnItemClickListener {
ListView mList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mList = (ListView) findViewById(android.R.id.list);
ArrayList<String> items = new ArrayList<>();
items.add("Support Examples");
items.add("Non-Support Examples");
mList.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, items));
mList.setOnItemClickListener(this);
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = null;
if (position == 0) { | // Path: app/src/main/java/com/github/dmcapps/navigationfragmentexample/v7/SupportExamplesActivity.java
// public class SupportExamplesActivity extends ActionBarActivity implements AdapterView.OnItemClickListener {
//
// ListView mList;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_main);
//
// mList = (ListView) findViewById(android.R.id.list);
//
// ArrayList<String> items = new ArrayList<>();
// items.add("Single Stack Example");
// items.add("Tab Example");
// items.add("Navigation Drawer Example (uses replace and remove as well as non-Navigation Fragments)");
// items.add("Override Default Animations Example");
// items.add("Navigation Fragment with View Pager. Navigating on view pager tab and view pager itself (git issue 5)");
// items.add("Navigation Fragment with View Pager and SmartTabLayout. Navigating on view pager tab and view pager itself (git issue 10)");
// items.add("Navigation Fragment clears stack before presenting");
//
// mList.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, items));
// mList.setOnItemClickListener(this);
// }
//
// @Override
// public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// Intent intent = null;
//
// if (position == 0) {
// intent = new Intent(this, SingleStackNavigationExampleActivity.class);
// } else if (position == 1) {
// intent = new Intent(this, ViewPagerNavigationExampleActivity.class);
// } else if (position == 2) {
// intent = new Intent(this, NavigationDrawerExampleActivity.class);
// } else if (position == 3) {
// intent = new Intent(this, OverrideDefaultAnimationsExampleActivity.class);
// } else if (position == 4) {
// intent = new Intent(this, GitIssue5ExampleActivity.class);
// } else if (position == 5) {
// intent = new Intent(this, GitIssue10ExampleActivity.class);
// } else if (position == 6) {
// intent = new Intent(this, NavigationDrawerClearStackExampleActivity.class);
// }
//
// startActivity(intent);
// }
// }
//
// Path: app/src/main/java/com/github/dmcapps/navigationfragmentexample/v17/NonSupportExamplesActivity.java
// public class NonSupportExamplesActivity extends ActionBarActivity implements AdapterView.OnItemClickListener {
//
// ListView mList;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_main);
//
// mList = (ListView) findViewById(android.R.id.list);
//
// ArrayList<String> items = new ArrayList<>();
// items.add("Single Stack Example");
// items.add("Tab Example");
// items.add("Navigation Drawer Example (uses replace and remove as well as non-Navigation Fragments)");
// items.add("Override Default Animations Example");
// items.add("Navigation Fragment clears stack before presenting");
// items.add("Transition Example");
//
// mList.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, items));
// mList.setOnItemClickListener(this);
// }
//
// @Override
// public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// Intent intent = null;
//
// if (position == 0) {
// intent = new Intent(this, SingleStackNavigationExampleActivity.class);
// } else if (position == 1) {
// intent = new Intent(this, ViewPagerNavigationExampleActivity.class);
// } else if (position == 2) {
// intent = new Intent(this, NavigationDrawerExampleActivity.class);
// } else if (position == 3) {
// intent = new Intent(this, OverrideDefaultAnimationsExampleActivity.class);
// } else if (position == 4) {
// intent = new Intent(this, NavigationDrawerClearStackExampleActivity.class);
// } else if (position == 5) {
// intent = new Intent(this, TransitionExampleActivity.class);
// }
//
// startActivity(intent);
// }
// }
// Path: app/src/main/java/com/github/dmcapps/navigationfragmentexample/MainActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import com.github.dmcapps.navigationfragmentexample.v7.SupportExamplesActivity;
import com.github.dmcapps.navigationfragmentexample.v17.NonSupportExamplesActivity;
import java.util.ArrayList;
package com.github.dmcapps.navigationfragmentexample;
public class MainActivity extends ActionBarActivity implements AdapterView.OnItemClickListener {
ListView mList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mList = (ListView) findViewById(android.R.id.list);
ArrayList<String> items = new ArrayList<>();
items.add("Support Examples");
items.add("Non-Support Examples");
mList.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, items));
mList.setOnItemClickListener(this);
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = null;
if (position == 0) { | intent = new Intent(this, SupportExamplesActivity.class); |
DMCApps/NavigationFragment | app/src/main/java/com/github/dmcapps/navigationfragmentexample/MainActivity.java | // Path: app/src/main/java/com/github/dmcapps/navigationfragmentexample/v7/SupportExamplesActivity.java
// public class SupportExamplesActivity extends ActionBarActivity implements AdapterView.OnItemClickListener {
//
// ListView mList;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_main);
//
// mList = (ListView) findViewById(android.R.id.list);
//
// ArrayList<String> items = new ArrayList<>();
// items.add("Single Stack Example");
// items.add("Tab Example");
// items.add("Navigation Drawer Example (uses replace and remove as well as non-Navigation Fragments)");
// items.add("Override Default Animations Example");
// items.add("Navigation Fragment with View Pager. Navigating on view pager tab and view pager itself (git issue 5)");
// items.add("Navigation Fragment with View Pager and SmartTabLayout. Navigating on view pager tab and view pager itself (git issue 10)");
// items.add("Navigation Fragment clears stack before presenting");
//
// mList.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, items));
// mList.setOnItemClickListener(this);
// }
//
// @Override
// public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// Intent intent = null;
//
// if (position == 0) {
// intent = new Intent(this, SingleStackNavigationExampleActivity.class);
// } else if (position == 1) {
// intent = new Intent(this, ViewPagerNavigationExampleActivity.class);
// } else if (position == 2) {
// intent = new Intent(this, NavigationDrawerExampleActivity.class);
// } else if (position == 3) {
// intent = new Intent(this, OverrideDefaultAnimationsExampleActivity.class);
// } else if (position == 4) {
// intent = new Intent(this, GitIssue5ExampleActivity.class);
// } else if (position == 5) {
// intent = new Intent(this, GitIssue10ExampleActivity.class);
// } else if (position == 6) {
// intent = new Intent(this, NavigationDrawerClearStackExampleActivity.class);
// }
//
// startActivity(intent);
// }
// }
//
// Path: app/src/main/java/com/github/dmcapps/navigationfragmentexample/v17/NonSupportExamplesActivity.java
// public class NonSupportExamplesActivity extends ActionBarActivity implements AdapterView.OnItemClickListener {
//
// ListView mList;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_main);
//
// mList = (ListView) findViewById(android.R.id.list);
//
// ArrayList<String> items = new ArrayList<>();
// items.add("Single Stack Example");
// items.add("Tab Example");
// items.add("Navigation Drawer Example (uses replace and remove as well as non-Navigation Fragments)");
// items.add("Override Default Animations Example");
// items.add("Navigation Fragment clears stack before presenting");
// items.add("Transition Example");
//
// mList.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, items));
// mList.setOnItemClickListener(this);
// }
//
// @Override
// public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// Intent intent = null;
//
// if (position == 0) {
// intent = new Intent(this, SingleStackNavigationExampleActivity.class);
// } else if (position == 1) {
// intent = new Intent(this, ViewPagerNavigationExampleActivity.class);
// } else if (position == 2) {
// intent = new Intent(this, NavigationDrawerExampleActivity.class);
// } else if (position == 3) {
// intent = new Intent(this, OverrideDefaultAnimationsExampleActivity.class);
// } else if (position == 4) {
// intent = new Intent(this, NavigationDrawerClearStackExampleActivity.class);
// } else if (position == 5) {
// intent = new Intent(this, TransitionExampleActivity.class);
// }
//
// startActivity(intent);
// }
// }
| import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import com.github.dmcapps.navigationfragmentexample.v7.SupportExamplesActivity;
import com.github.dmcapps.navigationfragmentexample.v17.NonSupportExamplesActivity;
import java.util.ArrayList; | package com.github.dmcapps.navigationfragmentexample;
public class MainActivity extends ActionBarActivity implements AdapterView.OnItemClickListener {
ListView mList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mList = (ListView) findViewById(android.R.id.list);
ArrayList<String> items = new ArrayList<>();
items.add("Support Examples");
items.add("Non-Support Examples");
mList.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, items));
mList.setOnItemClickListener(this);
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = null;
if (position == 0) {
intent = new Intent(this, SupportExamplesActivity.class);
} else if (position == 1) { | // Path: app/src/main/java/com/github/dmcapps/navigationfragmentexample/v7/SupportExamplesActivity.java
// public class SupportExamplesActivity extends ActionBarActivity implements AdapterView.OnItemClickListener {
//
// ListView mList;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_main);
//
// mList = (ListView) findViewById(android.R.id.list);
//
// ArrayList<String> items = new ArrayList<>();
// items.add("Single Stack Example");
// items.add("Tab Example");
// items.add("Navigation Drawer Example (uses replace and remove as well as non-Navigation Fragments)");
// items.add("Override Default Animations Example");
// items.add("Navigation Fragment with View Pager. Navigating on view pager tab and view pager itself (git issue 5)");
// items.add("Navigation Fragment with View Pager and SmartTabLayout. Navigating on view pager tab and view pager itself (git issue 10)");
// items.add("Navigation Fragment clears stack before presenting");
//
// mList.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, items));
// mList.setOnItemClickListener(this);
// }
//
// @Override
// public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// Intent intent = null;
//
// if (position == 0) {
// intent = new Intent(this, SingleStackNavigationExampleActivity.class);
// } else if (position == 1) {
// intent = new Intent(this, ViewPagerNavigationExampleActivity.class);
// } else if (position == 2) {
// intent = new Intent(this, NavigationDrawerExampleActivity.class);
// } else if (position == 3) {
// intent = new Intent(this, OverrideDefaultAnimationsExampleActivity.class);
// } else if (position == 4) {
// intent = new Intent(this, GitIssue5ExampleActivity.class);
// } else if (position == 5) {
// intent = new Intent(this, GitIssue10ExampleActivity.class);
// } else if (position == 6) {
// intent = new Intent(this, NavigationDrawerClearStackExampleActivity.class);
// }
//
// startActivity(intent);
// }
// }
//
// Path: app/src/main/java/com/github/dmcapps/navigationfragmentexample/v17/NonSupportExamplesActivity.java
// public class NonSupportExamplesActivity extends ActionBarActivity implements AdapterView.OnItemClickListener {
//
// ListView mList;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_main);
//
// mList = (ListView) findViewById(android.R.id.list);
//
// ArrayList<String> items = new ArrayList<>();
// items.add("Single Stack Example");
// items.add("Tab Example");
// items.add("Navigation Drawer Example (uses replace and remove as well as non-Navigation Fragments)");
// items.add("Override Default Animations Example");
// items.add("Navigation Fragment clears stack before presenting");
// items.add("Transition Example");
//
// mList.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, items));
// mList.setOnItemClickListener(this);
// }
//
// @Override
// public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// Intent intent = null;
//
// if (position == 0) {
// intent = new Intent(this, SingleStackNavigationExampleActivity.class);
// } else if (position == 1) {
// intent = new Intent(this, ViewPagerNavigationExampleActivity.class);
// } else if (position == 2) {
// intent = new Intent(this, NavigationDrawerExampleActivity.class);
// } else if (position == 3) {
// intent = new Intent(this, OverrideDefaultAnimationsExampleActivity.class);
// } else if (position == 4) {
// intent = new Intent(this, NavigationDrawerClearStackExampleActivity.class);
// } else if (position == 5) {
// intent = new Intent(this, TransitionExampleActivity.class);
// }
//
// startActivity(intent);
// }
// }
// Path: app/src/main/java/com/github/dmcapps/navigationfragmentexample/MainActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import com.github.dmcapps.navigationfragmentexample.v7.SupportExamplesActivity;
import com.github.dmcapps.navigationfragmentexample.v17.NonSupportExamplesActivity;
import java.util.ArrayList;
package com.github.dmcapps.navigationfragmentexample;
public class MainActivity extends ActionBarActivity implements AdapterView.OnItemClickListener {
ListView mList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mList = (ListView) findViewById(android.R.id.list);
ArrayList<String> items = new ArrayList<>();
items.add("Support Examples");
items.add("Non-Support Examples");
mList.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, items));
mList.setOnItemClickListener(this);
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = null;
if (position == 0) {
intent = new Intent(this, SupportExamplesActivity.class);
} else if (position == 1) { | intent = new Intent(this, NonSupportExamplesActivity.class); |
DMCApps/NavigationFragment | navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/core/NavigationManager.java | // Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Lifecycle.java
// public interface Lifecycle extends Serializable {
//
// View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState);
//
// void onViewCreated(View view, NavigationManager navigationManager);
//
// void onResume(NavigationManager navigationManager);
//
// void onPause(NavigationManager navigationManager);
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Navigation.java
// public interface Navigation {
//
// String getNavTag();
//
// void setNavBundle(Bundle bundle);
// Bundle getNavBundle();
//
// NavigationManager getNavigationManager();
//
// /**
// * Begins a Transaction for presenting the next fragment allowing for overriding of animations, bundles, etc.
// *
// * @return
// * returns an instance of {@link PresentationTransaction} for the programmer to describe the next presentation
// */
// PresentationTransaction beginPresentation();
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// */
// void presentFragment(Navigation navFragment);
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// * Sends a Bundle with the Fragment that can be retrieved using {@link Navigation#getNavBundle()}
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// * @param
// * navBundle -> Bundle to add to the presenting of the Fragment.
// */
// void presentFragment(Navigation navFragment, Bundle navBundle);
//
// /**
// * Dimiss the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// */
// void dismissFragment();
//
// /**
// * Pop the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// *
// * @param
// * navBundle -> The navigation bundle to add to the fragment after the pop occurs
// */
// void dismissFragment(Bundle navBundle);
//
// /**
// * Dismiss all fragments to the given index in the stack
// */
// void dismissToIndex(int index);
//
// /**
// * Dismiss all fragments from the stack until we reach the Root Fragment (the fragment at the min stack size)
// */
// void dismissToRoot();
//
// /**
// * Remove all fragments from the stack including the Root. The add the given {@link Navigation}
// * as the new root fragment. The definition of the Root Fragment is the Fragment at the min stack size position.
// *
// * @param
// * navFragment -> The fragment that you would like as the new Root of the stack.
// */
// void replaceRootFragment(Navigation navFragment);
//
// void setTitle(String title);
// void setTitle(int resId);
// String getTitle();
//
// boolean isPortrait();
// boolean isTablet();
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/NavigationManagerContainer.java
// public interface NavigationManagerContainer {
//
// NavigationManager getNavigationManager();
//
// /**
// * Get the current {@link FragmentManager} from the {@link NavigationManager}
// *
// * @return
// * Returns the Child Fragment Manager of the current fragment as an object to maintain a generic instance between
// * support and non support fragments
// */
// Object getNavChildFragmentManager();
//
// Activity getFragmentActivity();
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/NavigationManagerListener.java
// public interface NavigationManagerListener {
// void didPresentFragment();
// void didDismissFragment();
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Stack.java
// public interface Stack extends Serializable {
//
// Navigation pushFragment(NavigationManager navigationManager, Navigation navFragment, PresentationTransaction transaction);
//
// Navigation popFragment(NavigationManager navigationManager, Bundle navBundle);
//
// void clearNavigationStackToIndex(NavigationManager navigationManager, int index);
//
// void clearNavigationStackToIndex(NavigationManager navigationManager, int index, boolean inclusive);
//
// Navigation getFragmentAtIndex(NavigationManager navigationManager, int index);
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/State.java
// public interface State extends Serializable {
//
// Stack<String> getStack();
//
// void isTablet(boolean isTablet);
//
// boolean isTablet();
//
// void isPortrait(boolean isPortrait);
//
// boolean isPortrait();
// }
| import android.os.Bundle;
import android.util.Log;
import com.github.dmcapps.navigationfragment.common.interfaces.Lifecycle;
import com.github.dmcapps.navigationfragment.common.interfaces.Navigation;
import com.github.dmcapps.navigationfragment.common.interfaces.NavigationManagerContainer;
import com.github.dmcapps.navigationfragment.common.interfaces.NavigationManagerListener;
import com.github.dmcapps.navigationfragment.common.interfaces.Stack;
import com.github.dmcapps.navigationfragment.common.interfaces.State;
import java.io.Serializable;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List; | package com.github.dmcapps.navigationfragment.common.core;
/**
* Created by dcarmo on 2016-12-18.
*/
public class NavigationManager implements Serializable {
private static final String TAG = NavigationManager.class.getSimpleName();
| // Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Lifecycle.java
// public interface Lifecycle extends Serializable {
//
// View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState);
//
// void onViewCreated(View view, NavigationManager navigationManager);
//
// void onResume(NavigationManager navigationManager);
//
// void onPause(NavigationManager navigationManager);
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Navigation.java
// public interface Navigation {
//
// String getNavTag();
//
// void setNavBundle(Bundle bundle);
// Bundle getNavBundle();
//
// NavigationManager getNavigationManager();
//
// /**
// * Begins a Transaction for presenting the next fragment allowing for overriding of animations, bundles, etc.
// *
// * @return
// * returns an instance of {@link PresentationTransaction} for the programmer to describe the next presentation
// */
// PresentationTransaction beginPresentation();
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// */
// void presentFragment(Navigation navFragment);
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// * Sends a Bundle with the Fragment that can be retrieved using {@link Navigation#getNavBundle()}
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// * @param
// * navBundle -> Bundle to add to the presenting of the Fragment.
// */
// void presentFragment(Navigation navFragment, Bundle navBundle);
//
// /**
// * Dimiss the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// */
// void dismissFragment();
//
// /**
// * Pop the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// *
// * @param
// * navBundle -> The navigation bundle to add to the fragment after the pop occurs
// */
// void dismissFragment(Bundle navBundle);
//
// /**
// * Dismiss all fragments to the given index in the stack
// */
// void dismissToIndex(int index);
//
// /**
// * Dismiss all fragments from the stack until we reach the Root Fragment (the fragment at the min stack size)
// */
// void dismissToRoot();
//
// /**
// * Remove all fragments from the stack including the Root. The add the given {@link Navigation}
// * as the new root fragment. The definition of the Root Fragment is the Fragment at the min stack size position.
// *
// * @param
// * navFragment -> The fragment that you would like as the new Root of the stack.
// */
// void replaceRootFragment(Navigation navFragment);
//
// void setTitle(String title);
// void setTitle(int resId);
// String getTitle();
//
// boolean isPortrait();
// boolean isTablet();
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/NavigationManagerContainer.java
// public interface NavigationManagerContainer {
//
// NavigationManager getNavigationManager();
//
// /**
// * Get the current {@link FragmentManager} from the {@link NavigationManager}
// *
// * @return
// * Returns the Child Fragment Manager of the current fragment as an object to maintain a generic instance between
// * support and non support fragments
// */
// Object getNavChildFragmentManager();
//
// Activity getFragmentActivity();
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/NavigationManagerListener.java
// public interface NavigationManagerListener {
// void didPresentFragment();
// void didDismissFragment();
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Stack.java
// public interface Stack extends Serializable {
//
// Navigation pushFragment(NavigationManager navigationManager, Navigation navFragment, PresentationTransaction transaction);
//
// Navigation popFragment(NavigationManager navigationManager, Bundle navBundle);
//
// void clearNavigationStackToIndex(NavigationManager navigationManager, int index);
//
// void clearNavigationStackToIndex(NavigationManager navigationManager, int index, boolean inclusive);
//
// Navigation getFragmentAtIndex(NavigationManager navigationManager, int index);
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/State.java
// public interface State extends Serializable {
//
// Stack<String> getStack();
//
// void isTablet(boolean isTablet);
//
// boolean isTablet();
//
// void isPortrait(boolean isPortrait);
//
// boolean isPortrait();
// }
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/core/NavigationManager.java
import android.os.Bundle;
import android.util.Log;
import com.github.dmcapps.navigationfragment.common.interfaces.Lifecycle;
import com.github.dmcapps.navigationfragment.common.interfaces.Navigation;
import com.github.dmcapps.navigationfragment.common.interfaces.NavigationManagerContainer;
import com.github.dmcapps.navigationfragment.common.interfaces.NavigationManagerListener;
import com.github.dmcapps.navigationfragment.common.interfaces.Stack;
import com.github.dmcapps.navigationfragment.common.interfaces.State;
import java.io.Serializable;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
package com.github.dmcapps.navigationfragment.common.core;
/**
* Created by dcarmo on 2016-12-18.
*/
public class NavigationManager implements Serializable {
private static final String TAG = NavigationManager.class.getSimpleName();
| private transient NavigationManagerListener mListener; |
DMCApps/NavigationFragment | navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/core/NavigationManager.java | // Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Lifecycle.java
// public interface Lifecycle extends Serializable {
//
// View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState);
//
// void onViewCreated(View view, NavigationManager navigationManager);
//
// void onResume(NavigationManager navigationManager);
//
// void onPause(NavigationManager navigationManager);
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Navigation.java
// public interface Navigation {
//
// String getNavTag();
//
// void setNavBundle(Bundle bundle);
// Bundle getNavBundle();
//
// NavigationManager getNavigationManager();
//
// /**
// * Begins a Transaction for presenting the next fragment allowing for overriding of animations, bundles, etc.
// *
// * @return
// * returns an instance of {@link PresentationTransaction} for the programmer to describe the next presentation
// */
// PresentationTransaction beginPresentation();
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// */
// void presentFragment(Navigation navFragment);
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// * Sends a Bundle with the Fragment that can be retrieved using {@link Navigation#getNavBundle()}
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// * @param
// * navBundle -> Bundle to add to the presenting of the Fragment.
// */
// void presentFragment(Navigation navFragment, Bundle navBundle);
//
// /**
// * Dimiss the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// */
// void dismissFragment();
//
// /**
// * Pop the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// *
// * @param
// * navBundle -> The navigation bundle to add to the fragment after the pop occurs
// */
// void dismissFragment(Bundle navBundle);
//
// /**
// * Dismiss all fragments to the given index in the stack
// */
// void dismissToIndex(int index);
//
// /**
// * Dismiss all fragments from the stack until we reach the Root Fragment (the fragment at the min stack size)
// */
// void dismissToRoot();
//
// /**
// * Remove all fragments from the stack including the Root. The add the given {@link Navigation}
// * as the new root fragment. The definition of the Root Fragment is the Fragment at the min stack size position.
// *
// * @param
// * navFragment -> The fragment that you would like as the new Root of the stack.
// */
// void replaceRootFragment(Navigation navFragment);
//
// void setTitle(String title);
// void setTitle(int resId);
// String getTitle();
//
// boolean isPortrait();
// boolean isTablet();
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/NavigationManagerContainer.java
// public interface NavigationManagerContainer {
//
// NavigationManager getNavigationManager();
//
// /**
// * Get the current {@link FragmentManager} from the {@link NavigationManager}
// *
// * @return
// * Returns the Child Fragment Manager of the current fragment as an object to maintain a generic instance between
// * support and non support fragments
// */
// Object getNavChildFragmentManager();
//
// Activity getFragmentActivity();
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/NavigationManagerListener.java
// public interface NavigationManagerListener {
// void didPresentFragment();
// void didDismissFragment();
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Stack.java
// public interface Stack extends Serializable {
//
// Navigation pushFragment(NavigationManager navigationManager, Navigation navFragment, PresentationTransaction transaction);
//
// Navigation popFragment(NavigationManager navigationManager, Bundle navBundle);
//
// void clearNavigationStackToIndex(NavigationManager navigationManager, int index);
//
// void clearNavigationStackToIndex(NavigationManager navigationManager, int index, boolean inclusive);
//
// Navigation getFragmentAtIndex(NavigationManager navigationManager, int index);
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/State.java
// public interface State extends Serializable {
//
// Stack<String> getStack();
//
// void isTablet(boolean isTablet);
//
// boolean isTablet();
//
// void isPortrait(boolean isPortrait);
//
// boolean isPortrait();
// }
| import android.os.Bundle;
import android.util.Log;
import com.github.dmcapps.navigationfragment.common.interfaces.Lifecycle;
import com.github.dmcapps.navigationfragment.common.interfaces.Navigation;
import com.github.dmcapps.navigationfragment.common.interfaces.NavigationManagerContainer;
import com.github.dmcapps.navigationfragment.common.interfaces.NavigationManagerListener;
import com.github.dmcapps.navigationfragment.common.interfaces.Stack;
import com.github.dmcapps.navigationfragment.common.interfaces.State;
import java.io.Serializable;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List; | package com.github.dmcapps.navigationfragment.common.core;
/**
* Created by dcarmo on 2016-12-18.
*/
public class NavigationManager implements Serializable {
private static final String TAG = NavigationManager.class.getSimpleName();
private transient NavigationManagerListener mListener; | // Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Lifecycle.java
// public interface Lifecycle extends Serializable {
//
// View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState);
//
// void onViewCreated(View view, NavigationManager navigationManager);
//
// void onResume(NavigationManager navigationManager);
//
// void onPause(NavigationManager navigationManager);
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Navigation.java
// public interface Navigation {
//
// String getNavTag();
//
// void setNavBundle(Bundle bundle);
// Bundle getNavBundle();
//
// NavigationManager getNavigationManager();
//
// /**
// * Begins a Transaction for presenting the next fragment allowing for overriding of animations, bundles, etc.
// *
// * @return
// * returns an instance of {@link PresentationTransaction} for the programmer to describe the next presentation
// */
// PresentationTransaction beginPresentation();
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// */
// void presentFragment(Navigation navFragment);
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// * Sends a Bundle with the Fragment that can be retrieved using {@link Navigation#getNavBundle()}
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// * @param
// * navBundle -> Bundle to add to the presenting of the Fragment.
// */
// void presentFragment(Navigation navFragment, Bundle navBundle);
//
// /**
// * Dimiss the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// */
// void dismissFragment();
//
// /**
// * Pop the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// *
// * @param
// * navBundle -> The navigation bundle to add to the fragment after the pop occurs
// */
// void dismissFragment(Bundle navBundle);
//
// /**
// * Dismiss all fragments to the given index in the stack
// */
// void dismissToIndex(int index);
//
// /**
// * Dismiss all fragments from the stack until we reach the Root Fragment (the fragment at the min stack size)
// */
// void dismissToRoot();
//
// /**
// * Remove all fragments from the stack including the Root. The add the given {@link Navigation}
// * as the new root fragment. The definition of the Root Fragment is the Fragment at the min stack size position.
// *
// * @param
// * navFragment -> The fragment that you would like as the new Root of the stack.
// */
// void replaceRootFragment(Navigation navFragment);
//
// void setTitle(String title);
// void setTitle(int resId);
// String getTitle();
//
// boolean isPortrait();
// boolean isTablet();
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/NavigationManagerContainer.java
// public interface NavigationManagerContainer {
//
// NavigationManager getNavigationManager();
//
// /**
// * Get the current {@link FragmentManager} from the {@link NavigationManager}
// *
// * @return
// * Returns the Child Fragment Manager of the current fragment as an object to maintain a generic instance between
// * support and non support fragments
// */
// Object getNavChildFragmentManager();
//
// Activity getFragmentActivity();
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/NavigationManagerListener.java
// public interface NavigationManagerListener {
// void didPresentFragment();
// void didDismissFragment();
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Stack.java
// public interface Stack extends Serializable {
//
// Navigation pushFragment(NavigationManager navigationManager, Navigation navFragment, PresentationTransaction transaction);
//
// Navigation popFragment(NavigationManager navigationManager, Bundle navBundle);
//
// void clearNavigationStackToIndex(NavigationManager navigationManager, int index);
//
// void clearNavigationStackToIndex(NavigationManager navigationManager, int index, boolean inclusive);
//
// Navigation getFragmentAtIndex(NavigationManager navigationManager, int index);
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/State.java
// public interface State extends Serializable {
//
// Stack<String> getStack();
//
// void isTablet(boolean isTablet);
//
// boolean isTablet();
//
// void isPortrait(boolean isPortrait);
//
// boolean isPortrait();
// }
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/core/NavigationManager.java
import android.os.Bundle;
import android.util.Log;
import com.github.dmcapps.navigationfragment.common.interfaces.Lifecycle;
import com.github.dmcapps.navigationfragment.common.interfaces.Navigation;
import com.github.dmcapps.navigationfragment.common.interfaces.NavigationManagerContainer;
import com.github.dmcapps.navigationfragment.common.interfaces.NavigationManagerListener;
import com.github.dmcapps.navigationfragment.common.interfaces.Stack;
import com.github.dmcapps.navigationfragment.common.interfaces.State;
import java.io.Serializable;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
package com.github.dmcapps.navigationfragment.common.core;
/**
* Created by dcarmo on 2016-12-18.
*/
public class NavigationManager implements Serializable {
private static final String TAG = NavigationManager.class.getSimpleName();
private transient NavigationManagerListener mListener; | private transient WeakReference<NavigationManagerContainer> mContainer; |
DMCApps/NavigationFragment | navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/core/NavigationManager.java | // Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Lifecycle.java
// public interface Lifecycle extends Serializable {
//
// View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState);
//
// void onViewCreated(View view, NavigationManager navigationManager);
//
// void onResume(NavigationManager navigationManager);
//
// void onPause(NavigationManager navigationManager);
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Navigation.java
// public interface Navigation {
//
// String getNavTag();
//
// void setNavBundle(Bundle bundle);
// Bundle getNavBundle();
//
// NavigationManager getNavigationManager();
//
// /**
// * Begins a Transaction for presenting the next fragment allowing for overriding of animations, bundles, etc.
// *
// * @return
// * returns an instance of {@link PresentationTransaction} for the programmer to describe the next presentation
// */
// PresentationTransaction beginPresentation();
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// */
// void presentFragment(Navigation navFragment);
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// * Sends a Bundle with the Fragment that can be retrieved using {@link Navigation#getNavBundle()}
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// * @param
// * navBundle -> Bundle to add to the presenting of the Fragment.
// */
// void presentFragment(Navigation navFragment, Bundle navBundle);
//
// /**
// * Dimiss the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// */
// void dismissFragment();
//
// /**
// * Pop the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// *
// * @param
// * navBundle -> The navigation bundle to add to the fragment after the pop occurs
// */
// void dismissFragment(Bundle navBundle);
//
// /**
// * Dismiss all fragments to the given index in the stack
// */
// void dismissToIndex(int index);
//
// /**
// * Dismiss all fragments from the stack until we reach the Root Fragment (the fragment at the min stack size)
// */
// void dismissToRoot();
//
// /**
// * Remove all fragments from the stack including the Root. The add the given {@link Navigation}
// * as the new root fragment. The definition of the Root Fragment is the Fragment at the min stack size position.
// *
// * @param
// * navFragment -> The fragment that you would like as the new Root of the stack.
// */
// void replaceRootFragment(Navigation navFragment);
//
// void setTitle(String title);
// void setTitle(int resId);
// String getTitle();
//
// boolean isPortrait();
// boolean isTablet();
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/NavigationManagerContainer.java
// public interface NavigationManagerContainer {
//
// NavigationManager getNavigationManager();
//
// /**
// * Get the current {@link FragmentManager} from the {@link NavigationManager}
// *
// * @return
// * Returns the Child Fragment Manager of the current fragment as an object to maintain a generic instance between
// * support and non support fragments
// */
// Object getNavChildFragmentManager();
//
// Activity getFragmentActivity();
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/NavigationManagerListener.java
// public interface NavigationManagerListener {
// void didPresentFragment();
// void didDismissFragment();
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Stack.java
// public interface Stack extends Serializable {
//
// Navigation pushFragment(NavigationManager navigationManager, Navigation navFragment, PresentationTransaction transaction);
//
// Navigation popFragment(NavigationManager navigationManager, Bundle navBundle);
//
// void clearNavigationStackToIndex(NavigationManager navigationManager, int index);
//
// void clearNavigationStackToIndex(NavigationManager navigationManager, int index, boolean inclusive);
//
// Navigation getFragmentAtIndex(NavigationManager navigationManager, int index);
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/State.java
// public interface State extends Serializable {
//
// Stack<String> getStack();
//
// void isTablet(boolean isTablet);
//
// boolean isTablet();
//
// void isPortrait(boolean isPortrait);
//
// boolean isPortrait();
// }
| import android.os.Bundle;
import android.util.Log;
import com.github.dmcapps.navigationfragment.common.interfaces.Lifecycle;
import com.github.dmcapps.navigationfragment.common.interfaces.Navigation;
import com.github.dmcapps.navigationfragment.common.interfaces.NavigationManagerContainer;
import com.github.dmcapps.navigationfragment.common.interfaces.NavigationManagerListener;
import com.github.dmcapps.navigationfragment.common.interfaces.Stack;
import com.github.dmcapps.navigationfragment.common.interfaces.State;
import java.io.Serializable;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List; | package com.github.dmcapps.navigationfragment.common.core;
/**
* Created by dcarmo on 2016-12-18.
*/
public class NavigationManager implements Serializable {
private static final String TAG = NavigationManager.class.getSimpleName();
private transient NavigationManagerListener mListener;
private transient WeakReference<NavigationManagerContainer> mContainer;
// I don't like this ... but I'm having trouble thinking of a way to get rid of it ... | // Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Lifecycle.java
// public interface Lifecycle extends Serializable {
//
// View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState);
//
// void onViewCreated(View view, NavigationManager navigationManager);
//
// void onResume(NavigationManager navigationManager);
//
// void onPause(NavigationManager navigationManager);
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Navigation.java
// public interface Navigation {
//
// String getNavTag();
//
// void setNavBundle(Bundle bundle);
// Bundle getNavBundle();
//
// NavigationManager getNavigationManager();
//
// /**
// * Begins a Transaction for presenting the next fragment allowing for overriding of animations, bundles, etc.
// *
// * @return
// * returns an instance of {@link PresentationTransaction} for the programmer to describe the next presentation
// */
// PresentationTransaction beginPresentation();
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// */
// void presentFragment(Navigation navFragment);
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// * Sends a Bundle with the Fragment that can be retrieved using {@link Navigation#getNavBundle()}
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// * @param
// * navBundle -> Bundle to add to the presenting of the Fragment.
// */
// void presentFragment(Navigation navFragment, Bundle navBundle);
//
// /**
// * Dimiss the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// */
// void dismissFragment();
//
// /**
// * Pop the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// *
// * @param
// * navBundle -> The navigation bundle to add to the fragment after the pop occurs
// */
// void dismissFragment(Bundle navBundle);
//
// /**
// * Dismiss all fragments to the given index in the stack
// */
// void dismissToIndex(int index);
//
// /**
// * Dismiss all fragments from the stack until we reach the Root Fragment (the fragment at the min stack size)
// */
// void dismissToRoot();
//
// /**
// * Remove all fragments from the stack including the Root. The add the given {@link Navigation}
// * as the new root fragment. The definition of the Root Fragment is the Fragment at the min stack size position.
// *
// * @param
// * navFragment -> The fragment that you would like as the new Root of the stack.
// */
// void replaceRootFragment(Navigation navFragment);
//
// void setTitle(String title);
// void setTitle(int resId);
// String getTitle();
//
// boolean isPortrait();
// boolean isTablet();
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/NavigationManagerContainer.java
// public interface NavigationManagerContainer {
//
// NavigationManager getNavigationManager();
//
// /**
// * Get the current {@link FragmentManager} from the {@link NavigationManager}
// *
// * @return
// * Returns the Child Fragment Manager of the current fragment as an object to maintain a generic instance between
// * support and non support fragments
// */
// Object getNavChildFragmentManager();
//
// Activity getFragmentActivity();
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/NavigationManagerListener.java
// public interface NavigationManagerListener {
// void didPresentFragment();
// void didDismissFragment();
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Stack.java
// public interface Stack extends Serializable {
//
// Navigation pushFragment(NavigationManager navigationManager, Navigation navFragment, PresentationTransaction transaction);
//
// Navigation popFragment(NavigationManager navigationManager, Bundle navBundle);
//
// void clearNavigationStackToIndex(NavigationManager navigationManager, int index);
//
// void clearNavigationStackToIndex(NavigationManager navigationManager, int index, boolean inclusive);
//
// Navigation getFragmentAtIndex(NavigationManager navigationManager, int index);
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/State.java
// public interface State extends Serializable {
//
// Stack<String> getStack();
//
// void isTablet(boolean isTablet);
//
// boolean isTablet();
//
// void isPortrait(boolean isPortrait);
//
// boolean isPortrait();
// }
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/core/NavigationManager.java
import android.os.Bundle;
import android.util.Log;
import com.github.dmcapps.navigationfragment.common.interfaces.Lifecycle;
import com.github.dmcapps.navigationfragment.common.interfaces.Navigation;
import com.github.dmcapps.navigationfragment.common.interfaces.NavigationManagerContainer;
import com.github.dmcapps.navigationfragment.common.interfaces.NavigationManagerListener;
import com.github.dmcapps.navigationfragment.common.interfaces.Stack;
import com.github.dmcapps.navigationfragment.common.interfaces.State;
import java.io.Serializable;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
package com.github.dmcapps.navigationfragment.common.core;
/**
* Created by dcarmo on 2016-12-18.
*/
public class NavigationManager implements Serializable {
private static final String TAG = NavigationManager.class.getSimpleName();
private transient NavigationManagerListener mListener;
private transient WeakReference<NavigationManagerContainer> mContainer;
// I don't like this ... but I'm having trouble thinking of a way to get rid of it ... | private transient List<Navigation> mInitialNavigation; |
DMCApps/NavigationFragment | navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/core/NavigationManager.java | // Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Lifecycle.java
// public interface Lifecycle extends Serializable {
//
// View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState);
//
// void onViewCreated(View view, NavigationManager navigationManager);
//
// void onResume(NavigationManager navigationManager);
//
// void onPause(NavigationManager navigationManager);
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Navigation.java
// public interface Navigation {
//
// String getNavTag();
//
// void setNavBundle(Bundle bundle);
// Bundle getNavBundle();
//
// NavigationManager getNavigationManager();
//
// /**
// * Begins a Transaction for presenting the next fragment allowing for overriding of animations, bundles, etc.
// *
// * @return
// * returns an instance of {@link PresentationTransaction} for the programmer to describe the next presentation
// */
// PresentationTransaction beginPresentation();
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// */
// void presentFragment(Navigation navFragment);
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// * Sends a Bundle with the Fragment that can be retrieved using {@link Navigation#getNavBundle()}
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// * @param
// * navBundle -> Bundle to add to the presenting of the Fragment.
// */
// void presentFragment(Navigation navFragment, Bundle navBundle);
//
// /**
// * Dimiss the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// */
// void dismissFragment();
//
// /**
// * Pop the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// *
// * @param
// * navBundle -> The navigation bundle to add to the fragment after the pop occurs
// */
// void dismissFragment(Bundle navBundle);
//
// /**
// * Dismiss all fragments to the given index in the stack
// */
// void dismissToIndex(int index);
//
// /**
// * Dismiss all fragments from the stack until we reach the Root Fragment (the fragment at the min stack size)
// */
// void dismissToRoot();
//
// /**
// * Remove all fragments from the stack including the Root. The add the given {@link Navigation}
// * as the new root fragment. The definition of the Root Fragment is the Fragment at the min stack size position.
// *
// * @param
// * navFragment -> The fragment that you would like as the new Root of the stack.
// */
// void replaceRootFragment(Navigation navFragment);
//
// void setTitle(String title);
// void setTitle(int resId);
// String getTitle();
//
// boolean isPortrait();
// boolean isTablet();
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/NavigationManagerContainer.java
// public interface NavigationManagerContainer {
//
// NavigationManager getNavigationManager();
//
// /**
// * Get the current {@link FragmentManager} from the {@link NavigationManager}
// *
// * @return
// * Returns the Child Fragment Manager of the current fragment as an object to maintain a generic instance between
// * support and non support fragments
// */
// Object getNavChildFragmentManager();
//
// Activity getFragmentActivity();
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/NavigationManagerListener.java
// public interface NavigationManagerListener {
// void didPresentFragment();
// void didDismissFragment();
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Stack.java
// public interface Stack extends Serializable {
//
// Navigation pushFragment(NavigationManager navigationManager, Navigation navFragment, PresentationTransaction transaction);
//
// Navigation popFragment(NavigationManager navigationManager, Bundle navBundle);
//
// void clearNavigationStackToIndex(NavigationManager navigationManager, int index);
//
// void clearNavigationStackToIndex(NavigationManager navigationManager, int index, boolean inclusive);
//
// Navigation getFragmentAtIndex(NavigationManager navigationManager, int index);
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/State.java
// public interface State extends Serializable {
//
// Stack<String> getStack();
//
// void isTablet(boolean isTablet);
//
// boolean isTablet();
//
// void isPortrait(boolean isPortrait);
//
// boolean isPortrait();
// }
| import android.os.Bundle;
import android.util.Log;
import com.github.dmcapps.navigationfragment.common.interfaces.Lifecycle;
import com.github.dmcapps.navigationfragment.common.interfaces.Navigation;
import com.github.dmcapps.navigationfragment.common.interfaces.NavigationManagerContainer;
import com.github.dmcapps.navigationfragment.common.interfaces.NavigationManagerListener;
import com.github.dmcapps.navigationfragment.common.interfaces.Stack;
import com.github.dmcapps.navigationfragment.common.interfaces.State;
import java.io.Serializable;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List; | package com.github.dmcapps.navigationfragment.common.core;
/**
* Created by dcarmo on 2016-12-18.
*/
public class NavigationManager implements Serializable {
private static final String TAG = NavigationManager.class.getSimpleName();
private transient NavigationManagerListener mListener;
private transient WeakReference<NavigationManagerContainer> mContainer;
// I don't like this ... but I'm having trouble thinking of a way to get rid of it ...
private transient List<Navigation> mInitialNavigation;
private NavigationConfig mNavigationConfig;
| // Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Lifecycle.java
// public interface Lifecycle extends Serializable {
//
// View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState);
//
// void onViewCreated(View view, NavigationManager navigationManager);
//
// void onResume(NavigationManager navigationManager);
//
// void onPause(NavigationManager navigationManager);
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Navigation.java
// public interface Navigation {
//
// String getNavTag();
//
// void setNavBundle(Bundle bundle);
// Bundle getNavBundle();
//
// NavigationManager getNavigationManager();
//
// /**
// * Begins a Transaction for presenting the next fragment allowing for overriding of animations, bundles, etc.
// *
// * @return
// * returns an instance of {@link PresentationTransaction} for the programmer to describe the next presentation
// */
// PresentationTransaction beginPresentation();
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// */
// void presentFragment(Navigation navFragment);
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// * Sends a Bundle with the Fragment that can be retrieved using {@link Navigation#getNavBundle()}
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// * @param
// * navBundle -> Bundle to add to the presenting of the Fragment.
// */
// void presentFragment(Navigation navFragment, Bundle navBundle);
//
// /**
// * Dimiss the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// */
// void dismissFragment();
//
// /**
// * Pop the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// *
// * @param
// * navBundle -> The navigation bundle to add to the fragment after the pop occurs
// */
// void dismissFragment(Bundle navBundle);
//
// /**
// * Dismiss all fragments to the given index in the stack
// */
// void dismissToIndex(int index);
//
// /**
// * Dismiss all fragments from the stack until we reach the Root Fragment (the fragment at the min stack size)
// */
// void dismissToRoot();
//
// /**
// * Remove all fragments from the stack including the Root. The add the given {@link Navigation}
// * as the new root fragment. The definition of the Root Fragment is the Fragment at the min stack size position.
// *
// * @param
// * navFragment -> The fragment that you would like as the new Root of the stack.
// */
// void replaceRootFragment(Navigation navFragment);
//
// void setTitle(String title);
// void setTitle(int resId);
// String getTitle();
//
// boolean isPortrait();
// boolean isTablet();
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/NavigationManagerContainer.java
// public interface NavigationManagerContainer {
//
// NavigationManager getNavigationManager();
//
// /**
// * Get the current {@link FragmentManager} from the {@link NavigationManager}
// *
// * @return
// * Returns the Child Fragment Manager of the current fragment as an object to maintain a generic instance between
// * support and non support fragments
// */
// Object getNavChildFragmentManager();
//
// Activity getFragmentActivity();
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/NavigationManagerListener.java
// public interface NavigationManagerListener {
// void didPresentFragment();
// void didDismissFragment();
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Stack.java
// public interface Stack extends Serializable {
//
// Navigation pushFragment(NavigationManager navigationManager, Navigation navFragment, PresentationTransaction transaction);
//
// Navigation popFragment(NavigationManager navigationManager, Bundle navBundle);
//
// void clearNavigationStackToIndex(NavigationManager navigationManager, int index);
//
// void clearNavigationStackToIndex(NavigationManager navigationManager, int index, boolean inclusive);
//
// Navigation getFragmentAtIndex(NavigationManager navigationManager, int index);
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/State.java
// public interface State extends Serializable {
//
// Stack<String> getStack();
//
// void isTablet(boolean isTablet);
//
// boolean isTablet();
//
// void isPortrait(boolean isPortrait);
//
// boolean isPortrait();
// }
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/core/NavigationManager.java
import android.os.Bundle;
import android.util.Log;
import com.github.dmcapps.navigationfragment.common.interfaces.Lifecycle;
import com.github.dmcapps.navigationfragment.common.interfaces.Navigation;
import com.github.dmcapps.navigationfragment.common.interfaces.NavigationManagerContainer;
import com.github.dmcapps.navigationfragment.common.interfaces.NavigationManagerListener;
import com.github.dmcapps.navigationfragment.common.interfaces.Stack;
import com.github.dmcapps.navigationfragment.common.interfaces.State;
import java.io.Serializable;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
package com.github.dmcapps.navigationfragment.common.core;
/**
* Created by dcarmo on 2016-12-18.
*/
public class NavigationManager implements Serializable {
private static final String TAG = NavigationManager.class.getSimpleName();
private transient NavigationManagerListener mListener;
private transient WeakReference<NavigationManagerContainer> mContainer;
// I don't like this ... but I'm having trouble thinking of a way to get rid of it ...
private transient List<Navigation> mInitialNavigation;
private NavigationConfig mNavigationConfig;
| private Lifecycle mLifecycle; |
DMCApps/NavigationFragment | navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/core/NavigationManager.java | // Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Lifecycle.java
// public interface Lifecycle extends Serializable {
//
// View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState);
//
// void onViewCreated(View view, NavigationManager navigationManager);
//
// void onResume(NavigationManager navigationManager);
//
// void onPause(NavigationManager navigationManager);
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Navigation.java
// public interface Navigation {
//
// String getNavTag();
//
// void setNavBundle(Bundle bundle);
// Bundle getNavBundle();
//
// NavigationManager getNavigationManager();
//
// /**
// * Begins a Transaction for presenting the next fragment allowing for overriding of animations, bundles, etc.
// *
// * @return
// * returns an instance of {@link PresentationTransaction} for the programmer to describe the next presentation
// */
// PresentationTransaction beginPresentation();
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// */
// void presentFragment(Navigation navFragment);
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// * Sends a Bundle with the Fragment that can be retrieved using {@link Navigation#getNavBundle()}
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// * @param
// * navBundle -> Bundle to add to the presenting of the Fragment.
// */
// void presentFragment(Navigation navFragment, Bundle navBundle);
//
// /**
// * Dimiss the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// */
// void dismissFragment();
//
// /**
// * Pop the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// *
// * @param
// * navBundle -> The navigation bundle to add to the fragment after the pop occurs
// */
// void dismissFragment(Bundle navBundle);
//
// /**
// * Dismiss all fragments to the given index in the stack
// */
// void dismissToIndex(int index);
//
// /**
// * Dismiss all fragments from the stack until we reach the Root Fragment (the fragment at the min stack size)
// */
// void dismissToRoot();
//
// /**
// * Remove all fragments from the stack including the Root. The add the given {@link Navigation}
// * as the new root fragment. The definition of the Root Fragment is the Fragment at the min stack size position.
// *
// * @param
// * navFragment -> The fragment that you would like as the new Root of the stack.
// */
// void replaceRootFragment(Navigation navFragment);
//
// void setTitle(String title);
// void setTitle(int resId);
// String getTitle();
//
// boolean isPortrait();
// boolean isTablet();
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/NavigationManagerContainer.java
// public interface NavigationManagerContainer {
//
// NavigationManager getNavigationManager();
//
// /**
// * Get the current {@link FragmentManager} from the {@link NavigationManager}
// *
// * @return
// * Returns the Child Fragment Manager of the current fragment as an object to maintain a generic instance between
// * support and non support fragments
// */
// Object getNavChildFragmentManager();
//
// Activity getFragmentActivity();
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/NavigationManagerListener.java
// public interface NavigationManagerListener {
// void didPresentFragment();
// void didDismissFragment();
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Stack.java
// public interface Stack extends Serializable {
//
// Navigation pushFragment(NavigationManager navigationManager, Navigation navFragment, PresentationTransaction transaction);
//
// Navigation popFragment(NavigationManager navigationManager, Bundle navBundle);
//
// void clearNavigationStackToIndex(NavigationManager navigationManager, int index);
//
// void clearNavigationStackToIndex(NavigationManager navigationManager, int index, boolean inclusive);
//
// Navigation getFragmentAtIndex(NavigationManager navigationManager, int index);
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/State.java
// public interface State extends Serializable {
//
// Stack<String> getStack();
//
// void isTablet(boolean isTablet);
//
// boolean isTablet();
//
// void isPortrait(boolean isPortrait);
//
// boolean isPortrait();
// }
| import android.os.Bundle;
import android.util.Log;
import com.github.dmcapps.navigationfragment.common.interfaces.Lifecycle;
import com.github.dmcapps.navigationfragment.common.interfaces.Navigation;
import com.github.dmcapps.navigationfragment.common.interfaces.NavigationManagerContainer;
import com.github.dmcapps.navigationfragment.common.interfaces.NavigationManagerListener;
import com.github.dmcapps.navigationfragment.common.interfaces.Stack;
import com.github.dmcapps.navigationfragment.common.interfaces.State;
import java.io.Serializable;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List; | package com.github.dmcapps.navigationfragment.common.core;
/**
* Created by dcarmo on 2016-12-18.
*/
public class NavigationManager implements Serializable {
private static final String TAG = NavigationManager.class.getSimpleName();
private transient NavigationManagerListener mListener;
private transient WeakReference<NavigationManagerContainer> mContainer;
// I don't like this ... but I'm having trouble thinking of a way to get rid of it ...
private transient List<Navigation> mInitialNavigation;
private NavigationConfig mNavigationConfig;
private Lifecycle mLifecycle; | // Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Lifecycle.java
// public interface Lifecycle extends Serializable {
//
// View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState);
//
// void onViewCreated(View view, NavigationManager navigationManager);
//
// void onResume(NavigationManager navigationManager);
//
// void onPause(NavigationManager navigationManager);
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Navigation.java
// public interface Navigation {
//
// String getNavTag();
//
// void setNavBundle(Bundle bundle);
// Bundle getNavBundle();
//
// NavigationManager getNavigationManager();
//
// /**
// * Begins a Transaction for presenting the next fragment allowing for overriding of animations, bundles, etc.
// *
// * @return
// * returns an instance of {@link PresentationTransaction} for the programmer to describe the next presentation
// */
// PresentationTransaction beginPresentation();
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// */
// void presentFragment(Navigation navFragment);
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// * Sends a Bundle with the Fragment that can be retrieved using {@link Navigation#getNavBundle()}
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// * @param
// * navBundle -> Bundle to add to the presenting of the Fragment.
// */
// void presentFragment(Navigation navFragment, Bundle navBundle);
//
// /**
// * Dimiss the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// */
// void dismissFragment();
//
// /**
// * Pop the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// *
// * @param
// * navBundle -> The navigation bundle to add to the fragment after the pop occurs
// */
// void dismissFragment(Bundle navBundle);
//
// /**
// * Dismiss all fragments to the given index in the stack
// */
// void dismissToIndex(int index);
//
// /**
// * Dismiss all fragments from the stack until we reach the Root Fragment (the fragment at the min stack size)
// */
// void dismissToRoot();
//
// /**
// * Remove all fragments from the stack including the Root. The add the given {@link Navigation}
// * as the new root fragment. The definition of the Root Fragment is the Fragment at the min stack size position.
// *
// * @param
// * navFragment -> The fragment that you would like as the new Root of the stack.
// */
// void replaceRootFragment(Navigation navFragment);
//
// void setTitle(String title);
// void setTitle(int resId);
// String getTitle();
//
// boolean isPortrait();
// boolean isTablet();
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/NavigationManagerContainer.java
// public interface NavigationManagerContainer {
//
// NavigationManager getNavigationManager();
//
// /**
// * Get the current {@link FragmentManager} from the {@link NavigationManager}
// *
// * @return
// * Returns the Child Fragment Manager of the current fragment as an object to maintain a generic instance between
// * support and non support fragments
// */
// Object getNavChildFragmentManager();
//
// Activity getFragmentActivity();
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/NavigationManagerListener.java
// public interface NavigationManagerListener {
// void didPresentFragment();
// void didDismissFragment();
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Stack.java
// public interface Stack extends Serializable {
//
// Navigation pushFragment(NavigationManager navigationManager, Navigation navFragment, PresentationTransaction transaction);
//
// Navigation popFragment(NavigationManager navigationManager, Bundle navBundle);
//
// void clearNavigationStackToIndex(NavigationManager navigationManager, int index);
//
// void clearNavigationStackToIndex(NavigationManager navigationManager, int index, boolean inclusive);
//
// Navigation getFragmentAtIndex(NavigationManager navigationManager, int index);
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/State.java
// public interface State extends Serializable {
//
// Stack<String> getStack();
//
// void isTablet(boolean isTablet);
//
// boolean isTablet();
//
// void isPortrait(boolean isPortrait);
//
// boolean isPortrait();
// }
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/core/NavigationManager.java
import android.os.Bundle;
import android.util.Log;
import com.github.dmcapps.navigationfragment.common.interfaces.Lifecycle;
import com.github.dmcapps.navigationfragment.common.interfaces.Navigation;
import com.github.dmcapps.navigationfragment.common.interfaces.NavigationManagerContainer;
import com.github.dmcapps.navigationfragment.common.interfaces.NavigationManagerListener;
import com.github.dmcapps.navigationfragment.common.interfaces.Stack;
import com.github.dmcapps.navigationfragment.common.interfaces.State;
import java.io.Serializable;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
package com.github.dmcapps.navigationfragment.common.core;
/**
* Created by dcarmo on 2016-12-18.
*/
public class NavigationManager implements Serializable {
private static final String TAG = NavigationManager.class.getSimpleName();
private transient NavigationManagerListener mListener;
private transient WeakReference<NavigationManagerContainer> mContainer;
// I don't like this ... but I'm having trouble thinking of a way to get rid of it ...
private transient List<Navigation> mInitialNavigation;
private NavigationConfig mNavigationConfig;
private Lifecycle mLifecycle; | private State mState; |
DMCApps/NavigationFragment | navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/core/NavigationManager.java | // Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Lifecycle.java
// public interface Lifecycle extends Serializable {
//
// View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState);
//
// void onViewCreated(View view, NavigationManager navigationManager);
//
// void onResume(NavigationManager navigationManager);
//
// void onPause(NavigationManager navigationManager);
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Navigation.java
// public interface Navigation {
//
// String getNavTag();
//
// void setNavBundle(Bundle bundle);
// Bundle getNavBundle();
//
// NavigationManager getNavigationManager();
//
// /**
// * Begins a Transaction for presenting the next fragment allowing for overriding of animations, bundles, etc.
// *
// * @return
// * returns an instance of {@link PresentationTransaction} for the programmer to describe the next presentation
// */
// PresentationTransaction beginPresentation();
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// */
// void presentFragment(Navigation navFragment);
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// * Sends a Bundle with the Fragment that can be retrieved using {@link Navigation#getNavBundle()}
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// * @param
// * navBundle -> Bundle to add to the presenting of the Fragment.
// */
// void presentFragment(Navigation navFragment, Bundle navBundle);
//
// /**
// * Dimiss the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// */
// void dismissFragment();
//
// /**
// * Pop the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// *
// * @param
// * navBundle -> The navigation bundle to add to the fragment after the pop occurs
// */
// void dismissFragment(Bundle navBundle);
//
// /**
// * Dismiss all fragments to the given index in the stack
// */
// void dismissToIndex(int index);
//
// /**
// * Dismiss all fragments from the stack until we reach the Root Fragment (the fragment at the min stack size)
// */
// void dismissToRoot();
//
// /**
// * Remove all fragments from the stack including the Root. The add the given {@link Navigation}
// * as the new root fragment. The definition of the Root Fragment is the Fragment at the min stack size position.
// *
// * @param
// * navFragment -> The fragment that you would like as the new Root of the stack.
// */
// void replaceRootFragment(Navigation navFragment);
//
// void setTitle(String title);
// void setTitle(int resId);
// String getTitle();
//
// boolean isPortrait();
// boolean isTablet();
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/NavigationManagerContainer.java
// public interface NavigationManagerContainer {
//
// NavigationManager getNavigationManager();
//
// /**
// * Get the current {@link FragmentManager} from the {@link NavigationManager}
// *
// * @return
// * Returns the Child Fragment Manager of the current fragment as an object to maintain a generic instance between
// * support and non support fragments
// */
// Object getNavChildFragmentManager();
//
// Activity getFragmentActivity();
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/NavigationManagerListener.java
// public interface NavigationManagerListener {
// void didPresentFragment();
// void didDismissFragment();
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Stack.java
// public interface Stack extends Serializable {
//
// Navigation pushFragment(NavigationManager navigationManager, Navigation navFragment, PresentationTransaction transaction);
//
// Navigation popFragment(NavigationManager navigationManager, Bundle navBundle);
//
// void clearNavigationStackToIndex(NavigationManager navigationManager, int index);
//
// void clearNavigationStackToIndex(NavigationManager navigationManager, int index, boolean inclusive);
//
// Navigation getFragmentAtIndex(NavigationManager navigationManager, int index);
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/State.java
// public interface State extends Serializable {
//
// Stack<String> getStack();
//
// void isTablet(boolean isTablet);
//
// boolean isTablet();
//
// void isPortrait(boolean isPortrait);
//
// boolean isPortrait();
// }
| import android.os.Bundle;
import android.util.Log;
import com.github.dmcapps.navigationfragment.common.interfaces.Lifecycle;
import com.github.dmcapps.navigationfragment.common.interfaces.Navigation;
import com.github.dmcapps.navigationfragment.common.interfaces.NavigationManagerContainer;
import com.github.dmcapps.navigationfragment.common.interfaces.NavigationManagerListener;
import com.github.dmcapps.navigationfragment.common.interfaces.Stack;
import com.github.dmcapps.navigationfragment.common.interfaces.State;
import java.io.Serializable;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List; | package com.github.dmcapps.navigationfragment.common.core;
/**
* Created by dcarmo on 2016-12-18.
*/
public class NavigationManager implements Serializable {
private static final String TAG = NavigationManager.class.getSimpleName();
private transient NavigationManagerListener mListener;
private transient WeakReference<NavigationManagerContainer> mContainer;
// I don't like this ... but I'm having trouble thinking of a way to get rid of it ...
private transient List<Navigation> mInitialNavigation;
private NavigationConfig mNavigationConfig;
private Lifecycle mLifecycle;
private State mState; | // Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Lifecycle.java
// public interface Lifecycle extends Serializable {
//
// View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState);
//
// void onViewCreated(View view, NavigationManager navigationManager);
//
// void onResume(NavigationManager navigationManager);
//
// void onPause(NavigationManager navigationManager);
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Navigation.java
// public interface Navigation {
//
// String getNavTag();
//
// void setNavBundle(Bundle bundle);
// Bundle getNavBundle();
//
// NavigationManager getNavigationManager();
//
// /**
// * Begins a Transaction for presenting the next fragment allowing for overriding of animations, bundles, etc.
// *
// * @return
// * returns an instance of {@link PresentationTransaction} for the programmer to describe the next presentation
// */
// PresentationTransaction beginPresentation();
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// */
// void presentFragment(Navigation navFragment);
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// * Sends a Bundle with the Fragment that can be retrieved using {@link Navigation#getNavBundle()}
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// * @param
// * navBundle -> Bundle to add to the presenting of the Fragment.
// */
// void presentFragment(Navigation navFragment, Bundle navBundle);
//
// /**
// * Dimiss the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// */
// void dismissFragment();
//
// /**
// * Pop the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// *
// * @param
// * navBundle -> The navigation bundle to add to the fragment after the pop occurs
// */
// void dismissFragment(Bundle navBundle);
//
// /**
// * Dismiss all fragments to the given index in the stack
// */
// void dismissToIndex(int index);
//
// /**
// * Dismiss all fragments from the stack until we reach the Root Fragment (the fragment at the min stack size)
// */
// void dismissToRoot();
//
// /**
// * Remove all fragments from the stack including the Root. The add the given {@link Navigation}
// * as the new root fragment. The definition of the Root Fragment is the Fragment at the min stack size position.
// *
// * @param
// * navFragment -> The fragment that you would like as the new Root of the stack.
// */
// void replaceRootFragment(Navigation navFragment);
//
// void setTitle(String title);
// void setTitle(int resId);
// String getTitle();
//
// boolean isPortrait();
// boolean isTablet();
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/NavigationManagerContainer.java
// public interface NavigationManagerContainer {
//
// NavigationManager getNavigationManager();
//
// /**
// * Get the current {@link FragmentManager} from the {@link NavigationManager}
// *
// * @return
// * Returns the Child Fragment Manager of the current fragment as an object to maintain a generic instance between
// * support and non support fragments
// */
// Object getNavChildFragmentManager();
//
// Activity getFragmentActivity();
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/NavigationManagerListener.java
// public interface NavigationManagerListener {
// void didPresentFragment();
// void didDismissFragment();
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Stack.java
// public interface Stack extends Serializable {
//
// Navigation pushFragment(NavigationManager navigationManager, Navigation navFragment, PresentationTransaction transaction);
//
// Navigation popFragment(NavigationManager navigationManager, Bundle navBundle);
//
// void clearNavigationStackToIndex(NavigationManager navigationManager, int index);
//
// void clearNavigationStackToIndex(NavigationManager navigationManager, int index, boolean inclusive);
//
// Navigation getFragmentAtIndex(NavigationManager navigationManager, int index);
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/State.java
// public interface State extends Serializable {
//
// Stack<String> getStack();
//
// void isTablet(boolean isTablet);
//
// boolean isTablet();
//
// void isPortrait(boolean isPortrait);
//
// boolean isPortrait();
// }
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/core/NavigationManager.java
import android.os.Bundle;
import android.util.Log;
import com.github.dmcapps.navigationfragment.common.interfaces.Lifecycle;
import com.github.dmcapps.navigationfragment.common.interfaces.Navigation;
import com.github.dmcapps.navigationfragment.common.interfaces.NavigationManagerContainer;
import com.github.dmcapps.navigationfragment.common.interfaces.NavigationManagerListener;
import com.github.dmcapps.navigationfragment.common.interfaces.Stack;
import com.github.dmcapps.navigationfragment.common.interfaces.State;
import java.io.Serializable;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
package com.github.dmcapps.navigationfragment.common.core;
/**
* Created by dcarmo on 2016-12-18.
*/
public class NavigationManager implements Serializable {
private static final String TAG = NavigationManager.class.getSimpleName();
private transient NavigationManagerListener mListener;
private transient WeakReference<NavigationManagerContainer> mContainer;
// I don't like this ... but I'm having trouble thinking of a way to get rid of it ...
private transient List<Navigation> mInitialNavigation;
private NavigationConfig mNavigationConfig;
private Lifecycle mLifecycle;
private State mState; | private Stack mStack; |
DMCApps/NavigationFragment | app/src/main/java/com/github/dmcapps/navigationfragmentexample/v7/GitIssue5Example/GitIssue5ExampleActivity.java | // Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/v7/NavigationFragment.java
// public class NavigationFragment extends Fragment implements Navigation {
//
// private final String TAG = UUID.randomUUID().toString();
// private String mTitle;
// // Need to store the bundle myself as you can't change the fragment.setArguments() bundle after the fragment has been presented.
// private Bundle mNavBundle;
//
// public NavigationFragment() { }
//
// @Override
// public String getNavTag() {
// return TAG;
// }
//
// @Override
// public void setNavBundle(Bundle navBundle) {
// mNavBundle = navBundle;
// }
//
// @Override
// public Bundle getNavBundle() {
// return mNavBundle;
// }
//
// /**
// * Get the {@link NavigationManagerFragment} of the Fragment in the stack. This method will crash with
// * a RuntimeException if no Parent fragment is a {@link NavigationManagerFragment}.
// *
// * @return
// * The Parent Fragment in the stack of fragments that is the Navigation Manager of the Fragment.
// */
// @Override
// public NavigationManager getNavigationManager() {
// Fragment parent = this;
//
// // Loop until we find a parent that is a NavigationFragmentManager or there are no parents left to check.
// do {
// parent = parent.getParentFragment();
//
// NavigationManagerContainer container = ObjectUtils.as(NavigationManagerFragment.class, parent);
// if (container != null) {
// return container.getNavigationManager();
// }
// } while(parent != null);
//
// throw new RuntimeException("No parent NavigationManagerFragment found. In order to use the Navigation Manager Fragment you must have a parent in your Fragment Manager.");
// }
//
// /**
// * Begins a Transaction for presenting the next fragment allowing for overriding of animations, bundles, etc.
// *
// * @return
// * returns an instance of {@link PresentationTransaction} for the programmer to describe the next presentation
// */
// @Override
// public PresentationTransaction beginPresentation() {
// return getNavigationManager().beginPresentation();
// }
//
// /**
// * Present a fragment on the Navigation Manager using the default slide in and out.
// *
// * @param
// * navFragment -> The Fragment to present.
// */
// @Override
// public void presentFragment(Navigation navFragment) {
// beginPresentation().presentFragment(navFragment);
// }
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// * Sends a Bundle with the Fragment that can be retrieved using {@link Navigation#getNavBundle()}
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// * @param
// * navBundle -> Bundle to add to the presenting of the Fragment.
// */
// public void presentFragment(Navigation navFragment, Bundle navBundle) {
// beginPresentation().setNavBundle(navBundle).presentFragment(navFragment);
// }
//
// /**
// * Dimiss the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// */
// @Override
// public void dismissFragment() {
// getNavigationManager().dismissFragment();
// }
//
// /**
// * Pop the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// *
// * @param
// * navBundle -> The navigation bundle to add to the fragment after the pop occurs
// */
// @Override
// public void dismissFragment(Bundle navBundle) {
// getNavigationManager().dismissFragment(navBundle);
// }
//
// /**
// * Dismiss all fragments to the given index in the stack (With 0 being the root fragment)
// */
// @Override
// public void dismissToIndex(int index) {
// getNavigationManager().clearNavigationStackToIndex(index);
// }
//
// /**
// * Dismiss all the fragments on the Navigation Manager stack until the root fragment using the default slide in and out.
// */
// @Override
// public void dismissToRoot() {
// getNavigationManager().clearNavigationStackToRoot();
// }
//
// /**
// * Dismiss all the fragments on the Navigation Manager stack including the root fragment using the default slide in and out.
// * Present a fragment on the Navigation Manager using the default slide in and out.
// *
// * @param
// * navFragment -> The Fragment to present.
// */
// @Override
// public void replaceRootFragment(Navigation navFragment) {
// getNavigationManager().replaceRootFragment(navFragment);
// }
//
// /**
// * A method for setting the title of the action bar. (Saves you from having to call getActivity().setTitle())
// *
// * @param
// * resId -> Resource Id of the title you would like to set.
// */
// @Override
// public void setTitle(int resId) {
// setTitle(getString(resId));
// }
//
// /**
// * A method for setting the title of the action bar. (Saves you from having to call getActivity().setTitle())
// *
// * @param
// * title -> String of the title you would like to set.
// */
// @Override
// public void setTitle(String title) {
// mTitle = title;
// ActionBarManager.setTitle(getActivity(), mTitle);
// }
//
// /**
// * A method for retrieving the currently set title for the NavigationFragment
// *
// * @return
// * The current title of the NavigationFragment
// */
// @Override
// public String getTitle() {
// return mTitle;
// }
//
// @Override
// public boolean isPortrait() {
// return getNavigationManager().isPortrait();
// }
//
// @Override
// public boolean isTablet() {
// return getNavigationManager().isTablet();
// }
// }
| import com.github.dmcapps.navigationfragment.v7.NavigationFragment; | package com.github.dmcapps.navigationfragmentexample.v7.GitIssue5Example;
public class GitIssue5ExampleActivity extends basicImplementation {
@Override | // Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/v7/NavigationFragment.java
// public class NavigationFragment extends Fragment implements Navigation {
//
// private final String TAG = UUID.randomUUID().toString();
// private String mTitle;
// // Need to store the bundle myself as you can't change the fragment.setArguments() bundle after the fragment has been presented.
// private Bundle mNavBundle;
//
// public NavigationFragment() { }
//
// @Override
// public String getNavTag() {
// return TAG;
// }
//
// @Override
// public void setNavBundle(Bundle navBundle) {
// mNavBundle = navBundle;
// }
//
// @Override
// public Bundle getNavBundle() {
// return mNavBundle;
// }
//
// /**
// * Get the {@link NavigationManagerFragment} of the Fragment in the stack. This method will crash with
// * a RuntimeException if no Parent fragment is a {@link NavigationManagerFragment}.
// *
// * @return
// * The Parent Fragment in the stack of fragments that is the Navigation Manager of the Fragment.
// */
// @Override
// public NavigationManager getNavigationManager() {
// Fragment parent = this;
//
// // Loop until we find a parent that is a NavigationFragmentManager or there are no parents left to check.
// do {
// parent = parent.getParentFragment();
//
// NavigationManagerContainer container = ObjectUtils.as(NavigationManagerFragment.class, parent);
// if (container != null) {
// return container.getNavigationManager();
// }
// } while(parent != null);
//
// throw new RuntimeException("No parent NavigationManagerFragment found. In order to use the Navigation Manager Fragment you must have a parent in your Fragment Manager.");
// }
//
// /**
// * Begins a Transaction for presenting the next fragment allowing for overriding of animations, bundles, etc.
// *
// * @return
// * returns an instance of {@link PresentationTransaction} for the programmer to describe the next presentation
// */
// @Override
// public PresentationTransaction beginPresentation() {
// return getNavigationManager().beginPresentation();
// }
//
// /**
// * Present a fragment on the Navigation Manager using the default slide in and out.
// *
// * @param
// * navFragment -> The Fragment to present.
// */
// @Override
// public void presentFragment(Navigation navFragment) {
// beginPresentation().presentFragment(navFragment);
// }
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// * Sends a Bundle with the Fragment that can be retrieved using {@link Navigation#getNavBundle()}
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// * @param
// * navBundle -> Bundle to add to the presenting of the Fragment.
// */
// public void presentFragment(Navigation navFragment, Bundle navBundle) {
// beginPresentation().setNavBundle(navBundle).presentFragment(navFragment);
// }
//
// /**
// * Dimiss the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// */
// @Override
// public void dismissFragment() {
// getNavigationManager().dismissFragment();
// }
//
// /**
// * Pop the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// *
// * @param
// * navBundle -> The navigation bundle to add to the fragment after the pop occurs
// */
// @Override
// public void dismissFragment(Bundle navBundle) {
// getNavigationManager().dismissFragment(navBundle);
// }
//
// /**
// * Dismiss all fragments to the given index in the stack (With 0 being the root fragment)
// */
// @Override
// public void dismissToIndex(int index) {
// getNavigationManager().clearNavigationStackToIndex(index);
// }
//
// /**
// * Dismiss all the fragments on the Navigation Manager stack until the root fragment using the default slide in and out.
// */
// @Override
// public void dismissToRoot() {
// getNavigationManager().clearNavigationStackToRoot();
// }
//
// /**
// * Dismiss all the fragments on the Navigation Manager stack including the root fragment using the default slide in and out.
// * Present a fragment on the Navigation Manager using the default slide in and out.
// *
// * @param
// * navFragment -> The Fragment to present.
// */
// @Override
// public void replaceRootFragment(Navigation navFragment) {
// getNavigationManager().replaceRootFragment(navFragment);
// }
//
// /**
// * A method for setting the title of the action bar. (Saves you from having to call getActivity().setTitle())
// *
// * @param
// * resId -> Resource Id of the title you would like to set.
// */
// @Override
// public void setTitle(int resId) {
// setTitle(getString(resId));
// }
//
// /**
// * A method for setting the title of the action bar. (Saves you from having to call getActivity().setTitle())
// *
// * @param
// * title -> String of the title you would like to set.
// */
// @Override
// public void setTitle(String title) {
// mTitle = title;
// ActionBarManager.setTitle(getActivity(), mTitle);
// }
//
// /**
// * A method for retrieving the currently set title for the NavigationFragment
// *
// * @return
// * The current title of the NavigationFragment
// */
// @Override
// public String getTitle() {
// return mTitle;
// }
//
// @Override
// public boolean isPortrait() {
// return getNavigationManager().isPortrait();
// }
//
// @Override
// public boolean isTablet() {
// return getNavigationManager().isTablet();
// }
// }
// Path: app/src/main/java/com/github/dmcapps/navigationfragmentexample/v7/GitIssue5Example/GitIssue5ExampleActivity.java
import com.github.dmcapps.navigationfragment.v7.NavigationFragment;
package com.github.dmcapps.navigationfragmentexample.v7.GitIssue5Example;
public class GitIssue5ExampleActivity extends basicImplementation {
@Override | protected NavigationFragment initFragment() { |
DMCApps/NavigationFragment | navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/core/PresentationTransaction.java | // Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Navigation.java
// public interface Navigation {
//
// String getNavTag();
//
// void setNavBundle(Bundle bundle);
// Bundle getNavBundle();
//
// NavigationManager getNavigationManager();
//
// /**
// * Begins a Transaction for presenting the next fragment allowing for overriding of animations, bundles, etc.
// *
// * @return
// * returns an instance of {@link PresentationTransaction} for the programmer to describe the next presentation
// */
// PresentationTransaction beginPresentation();
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// */
// void presentFragment(Navigation navFragment);
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// * Sends a Bundle with the Fragment that can be retrieved using {@link Navigation#getNavBundle()}
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// * @param
// * navBundle -> Bundle to add to the presenting of the Fragment.
// */
// void presentFragment(Navigation navFragment, Bundle navBundle);
//
// /**
// * Dimiss the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// */
// void dismissFragment();
//
// /**
// * Pop the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// *
// * @param
// * navBundle -> The navigation bundle to add to the fragment after the pop occurs
// */
// void dismissFragment(Bundle navBundle);
//
// /**
// * Dismiss all fragments to the given index in the stack
// */
// void dismissToIndex(int index);
//
// /**
// * Dismiss all fragments from the stack until we reach the Root Fragment (the fragment at the min stack size)
// */
// void dismissToRoot();
//
// /**
// * Remove all fragments from the stack including the Root. The add the given {@link Navigation}
// * as the new root fragment. The definition of the Root Fragment is the Fragment at the min stack size position.
// *
// * @param
// * navFragment -> The fragment that you would like as the new Root of the stack.
// */
// void replaceRootFragment(Navigation navFragment);
//
// void setTitle(String title);
// void setTitle(int resId);
// String getTitle();
//
// boolean isPortrait();
// boolean isTablet();
// }
| import android.os.Bundle;
import android.support.annotation.NonNull;
import android.transition.Transition;
import android.view.View;
import com.github.dmcapps.navigationfragment.common.interfaces.Navigation; |
Transition getSharedElementReturnTransition() {
return sharedElementReturnTransition;
}
public PresentationTransaction setNextFragmentEnterTransition(Transition transition) {
nextFragmentEnterTransition = transition;
return this;
}
Transition getNextFragmentEnterTransition() {
return nextFragmentEnterTransition;
}
*/
public PresentationTransaction setCustomAnimations(int enter, int exit) {
super.setCustomAnimations(enter, exit);
return this;
}
public PresentationTransaction setCustomAnimations(int enter, int exit, int popEnter, int popExit) {
super.setCustomAnimations(enter, exit, popEnter, popExit);
return this;
}
public PresentationTransaction addSharedElement(View view, String name) {
super.addSharedElement(view, name);
return this;
}
| // Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Navigation.java
// public interface Navigation {
//
// String getNavTag();
//
// void setNavBundle(Bundle bundle);
// Bundle getNavBundle();
//
// NavigationManager getNavigationManager();
//
// /**
// * Begins a Transaction for presenting the next fragment allowing for overriding of animations, bundles, etc.
// *
// * @return
// * returns an instance of {@link PresentationTransaction} for the programmer to describe the next presentation
// */
// PresentationTransaction beginPresentation();
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// */
// void presentFragment(Navigation navFragment);
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// * Sends a Bundle with the Fragment that can be retrieved using {@link Navigation#getNavBundle()}
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// * @param
// * navBundle -> Bundle to add to the presenting of the Fragment.
// */
// void presentFragment(Navigation navFragment, Bundle navBundle);
//
// /**
// * Dimiss the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// */
// void dismissFragment();
//
// /**
// * Pop the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// *
// * @param
// * navBundle -> The navigation bundle to add to the fragment after the pop occurs
// */
// void dismissFragment(Bundle navBundle);
//
// /**
// * Dismiss all fragments to the given index in the stack
// */
// void dismissToIndex(int index);
//
// /**
// * Dismiss all fragments from the stack until we reach the Root Fragment (the fragment at the min stack size)
// */
// void dismissToRoot();
//
// /**
// * Remove all fragments from the stack including the Root. The add the given {@link Navigation}
// * as the new root fragment. The definition of the Root Fragment is the Fragment at the min stack size position.
// *
// * @param
// * navFragment -> The fragment that you would like as the new Root of the stack.
// */
// void replaceRootFragment(Navigation navFragment);
//
// void setTitle(String title);
// void setTitle(int resId);
// String getTitle();
//
// boolean isPortrait();
// boolean isTablet();
// }
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/core/PresentationTransaction.java
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.transition.Transition;
import android.view.View;
import com.github.dmcapps.navigationfragment.common.interfaces.Navigation;
Transition getSharedElementReturnTransition() {
return sharedElementReturnTransition;
}
public PresentationTransaction setNextFragmentEnterTransition(Transition transition) {
nextFragmentEnterTransition = transition;
return this;
}
Transition getNextFragmentEnterTransition() {
return nextFragmentEnterTransition;
}
*/
public PresentationTransaction setCustomAnimations(int enter, int exit) {
super.setCustomAnimations(enter, exit);
return this;
}
public PresentationTransaction setCustomAnimations(int enter, int exit, int popEnter, int popExit) {
super.setCustomAnimations(enter, exit, popEnter, popExit);
return this;
}
public PresentationTransaction addSharedElement(View view, String name) {
super.addSharedElement(view, name);
return this;
}
| public void presentFragment(Navigation navFragment) { |
DMCApps/NavigationFragment | navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/core/StackManager.java | // Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Navigation.java
// public interface Navigation {
//
// String getNavTag();
//
// void setNavBundle(Bundle bundle);
// Bundle getNavBundle();
//
// NavigationManager getNavigationManager();
//
// /**
// * Begins a Transaction for presenting the next fragment allowing for overriding of animations, bundles, etc.
// *
// * @return
// * returns an instance of {@link PresentationTransaction} for the programmer to describe the next presentation
// */
// PresentationTransaction beginPresentation();
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// */
// void presentFragment(Navigation navFragment);
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// * Sends a Bundle with the Fragment that can be retrieved using {@link Navigation#getNavBundle()}
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// * @param
// * navBundle -> Bundle to add to the presenting of the Fragment.
// */
// void presentFragment(Navigation navFragment, Bundle navBundle);
//
// /**
// * Dimiss the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// */
// void dismissFragment();
//
// /**
// * Pop the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// *
// * @param
// * navBundle -> The navigation bundle to add to the fragment after the pop occurs
// */
// void dismissFragment(Bundle navBundle);
//
// /**
// * Dismiss all fragments to the given index in the stack
// */
// void dismissToIndex(int index);
//
// /**
// * Dismiss all fragments from the stack until we reach the Root Fragment (the fragment at the min stack size)
// */
// void dismissToRoot();
//
// /**
// * Remove all fragments from the stack including the Root. The add the given {@link Navigation}
// * as the new root fragment. The definition of the Root Fragment is the Fragment at the min stack size position.
// *
// * @param
// * navFragment -> The fragment that you would like as the new Root of the stack.
// */
// void replaceRootFragment(Navigation navFragment);
//
// void setTitle(String title);
// void setTitle(int resId);
// String getTitle();
//
// boolean isPortrait();
// boolean isTablet();
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Stack.java
// public interface Stack extends Serializable {
//
// Navigation pushFragment(NavigationManager navigationManager, Navigation navFragment, PresentationTransaction transaction);
//
// Navigation popFragment(NavigationManager navigationManager, Bundle navBundle);
//
// void clearNavigationStackToIndex(NavigationManager navigationManager, int index);
//
// void clearNavigationStackToIndex(NavigationManager navigationManager, int index, boolean inclusive);
//
// Navigation getFragmentAtIndex(NavigationManager navigationManager, int index);
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/State.java
// public interface State extends Serializable {
//
// Stack<String> getStack();
//
// void isTablet(boolean isTablet);
//
// boolean isTablet();
//
// void isPortrait(boolean isPortrait);
//
// boolean isPortrait();
// }
| import android.app.FragmentManager;
import android.os.Bundle;
import android.util.Log;
import com.github.dmcapps.navigationfragment.common.interfaces.Navigation;
import com.github.dmcapps.navigationfragment.common.interfaces.Stack;
import com.github.dmcapps.navigationfragment.common.interfaces.State;
import java.util.Locale; | package com.github.dmcapps.navigationfragment.common.core;
/**
* Created by dcarmo on 2016-11-19.
*/
public class StackManager implements Stack {
private static final String TAG = StackManager.class.getSimpleName();
@Override | // Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Navigation.java
// public interface Navigation {
//
// String getNavTag();
//
// void setNavBundle(Bundle bundle);
// Bundle getNavBundle();
//
// NavigationManager getNavigationManager();
//
// /**
// * Begins a Transaction for presenting the next fragment allowing for overriding of animations, bundles, etc.
// *
// * @return
// * returns an instance of {@link PresentationTransaction} for the programmer to describe the next presentation
// */
// PresentationTransaction beginPresentation();
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// */
// void presentFragment(Navigation navFragment);
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// * Sends a Bundle with the Fragment that can be retrieved using {@link Navigation#getNavBundle()}
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// * @param
// * navBundle -> Bundle to add to the presenting of the Fragment.
// */
// void presentFragment(Navigation navFragment, Bundle navBundle);
//
// /**
// * Dimiss the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// */
// void dismissFragment();
//
// /**
// * Pop the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// *
// * @param
// * navBundle -> The navigation bundle to add to the fragment after the pop occurs
// */
// void dismissFragment(Bundle navBundle);
//
// /**
// * Dismiss all fragments to the given index in the stack
// */
// void dismissToIndex(int index);
//
// /**
// * Dismiss all fragments from the stack until we reach the Root Fragment (the fragment at the min stack size)
// */
// void dismissToRoot();
//
// /**
// * Remove all fragments from the stack including the Root. The add the given {@link Navigation}
// * as the new root fragment. The definition of the Root Fragment is the Fragment at the min stack size position.
// *
// * @param
// * navFragment -> The fragment that you would like as the new Root of the stack.
// */
// void replaceRootFragment(Navigation navFragment);
//
// void setTitle(String title);
// void setTitle(int resId);
// String getTitle();
//
// boolean isPortrait();
// boolean isTablet();
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Stack.java
// public interface Stack extends Serializable {
//
// Navigation pushFragment(NavigationManager navigationManager, Navigation navFragment, PresentationTransaction transaction);
//
// Navigation popFragment(NavigationManager navigationManager, Bundle navBundle);
//
// void clearNavigationStackToIndex(NavigationManager navigationManager, int index);
//
// void clearNavigationStackToIndex(NavigationManager navigationManager, int index, boolean inclusive);
//
// Navigation getFragmentAtIndex(NavigationManager navigationManager, int index);
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/State.java
// public interface State extends Serializable {
//
// Stack<String> getStack();
//
// void isTablet(boolean isTablet);
//
// boolean isTablet();
//
// void isPortrait(boolean isPortrait);
//
// boolean isPortrait();
// }
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/core/StackManager.java
import android.app.FragmentManager;
import android.os.Bundle;
import android.util.Log;
import com.github.dmcapps.navigationfragment.common.interfaces.Navigation;
import com.github.dmcapps.navigationfragment.common.interfaces.Stack;
import com.github.dmcapps.navigationfragment.common.interfaces.State;
import java.util.Locale;
package com.github.dmcapps.navigationfragment.common.core;
/**
* Created by dcarmo on 2016-11-19.
*/
public class StackManager implements Stack {
private static final String TAG = StackManager.class.getSimpleName();
@Override | public Navigation pushFragment(NavigationManager navigationManager, Navigation navFragment, PresentationTransaction transaction) { |
DMCApps/NavigationFragment | navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/core/StackManager.java | // Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Navigation.java
// public interface Navigation {
//
// String getNavTag();
//
// void setNavBundle(Bundle bundle);
// Bundle getNavBundle();
//
// NavigationManager getNavigationManager();
//
// /**
// * Begins a Transaction for presenting the next fragment allowing for overriding of animations, bundles, etc.
// *
// * @return
// * returns an instance of {@link PresentationTransaction} for the programmer to describe the next presentation
// */
// PresentationTransaction beginPresentation();
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// */
// void presentFragment(Navigation navFragment);
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// * Sends a Bundle with the Fragment that can be retrieved using {@link Navigation#getNavBundle()}
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// * @param
// * navBundle -> Bundle to add to the presenting of the Fragment.
// */
// void presentFragment(Navigation navFragment, Bundle navBundle);
//
// /**
// * Dimiss the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// */
// void dismissFragment();
//
// /**
// * Pop the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// *
// * @param
// * navBundle -> The navigation bundle to add to the fragment after the pop occurs
// */
// void dismissFragment(Bundle navBundle);
//
// /**
// * Dismiss all fragments to the given index in the stack
// */
// void dismissToIndex(int index);
//
// /**
// * Dismiss all fragments from the stack until we reach the Root Fragment (the fragment at the min stack size)
// */
// void dismissToRoot();
//
// /**
// * Remove all fragments from the stack including the Root. The add the given {@link Navigation}
// * as the new root fragment. The definition of the Root Fragment is the Fragment at the min stack size position.
// *
// * @param
// * navFragment -> The fragment that you would like as the new Root of the stack.
// */
// void replaceRootFragment(Navigation navFragment);
//
// void setTitle(String title);
// void setTitle(int resId);
// String getTitle();
//
// boolean isPortrait();
// boolean isTablet();
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Stack.java
// public interface Stack extends Serializable {
//
// Navigation pushFragment(NavigationManager navigationManager, Navigation navFragment, PresentationTransaction transaction);
//
// Navigation popFragment(NavigationManager navigationManager, Bundle navBundle);
//
// void clearNavigationStackToIndex(NavigationManager navigationManager, int index);
//
// void clearNavigationStackToIndex(NavigationManager navigationManager, int index, boolean inclusive);
//
// Navigation getFragmentAtIndex(NavigationManager navigationManager, int index);
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/State.java
// public interface State extends Serializable {
//
// Stack<String> getStack();
//
// void isTablet(boolean isTablet);
//
// boolean isTablet();
//
// void isPortrait(boolean isPortrait);
//
// boolean isPortrait();
// }
| import android.app.FragmentManager;
import android.os.Bundle;
import android.util.Log;
import com.github.dmcapps.navigationfragment.common.interfaces.Navigation;
import com.github.dmcapps.navigationfragment.common.interfaces.Stack;
import com.github.dmcapps.navigationfragment.common.interfaces.State;
import java.util.Locale; | package com.github.dmcapps.navigationfragment.common.core;
/**
* Created by dcarmo on 2016-11-19.
*/
public class StackManager implements Stack {
private static final String TAG = StackManager.class.getSimpleName();
@Override
public Navigation pushFragment(NavigationManager navigationManager, Navigation navFragment, PresentationTransaction transaction) {
NavigationConfig config = navigationManager.getConfig();
if (transaction.getNavBundle() != null) {
navFragment.setNavBundle(transaction.getNavBundle());
}
// Don't animate the initial fragments being added to the stack.
if (navigationManager.getCurrentStackSize() < config.getMinStackSize()) {
transaction.setCustomAnimations(0, 0, 0, 0);
}
// Add in the new fragment that we are presenting and add it's navigation tag to the stack.
transaction.add(config.getPushContainerId(), navFragment, navFragment.getNavTag());
transaction.addToBackStack(navFragment.getNavTag());
transaction.commit();
navigationManager.addToStack(navFragment);
return navFragment;
}
@Override
public Navigation popFragment(NavigationManager navigationManager, Bundle navBundle) {
Navigation navFragment = null;
| // Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Navigation.java
// public interface Navigation {
//
// String getNavTag();
//
// void setNavBundle(Bundle bundle);
// Bundle getNavBundle();
//
// NavigationManager getNavigationManager();
//
// /**
// * Begins a Transaction for presenting the next fragment allowing for overriding of animations, bundles, etc.
// *
// * @return
// * returns an instance of {@link PresentationTransaction} for the programmer to describe the next presentation
// */
// PresentationTransaction beginPresentation();
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// */
// void presentFragment(Navigation navFragment);
//
// /**
// * Push a new Fragment onto the stack and presenting it to the screen
// * Uses default animation of slide in from right and slide out to left.
// * Sends a Bundle with the Fragment that can be retrieved using {@link Navigation#getNavBundle()}
// *
// * @param
// * navFragment -> The Fragment to show. It must be a Fragment that implements {@link Navigation}
// * @param
// * navBundle -> Bundle to add to the presenting of the Fragment.
// */
// void presentFragment(Navigation navFragment, Bundle navBundle);
//
// /**
// * Dimiss the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// */
// void dismissFragment();
//
// /**
// * Pop the current fragment off the top of the stack and dismiss it.
// * Uses default animation of slide in from left and slide out to right animation.
// *
// * @param
// * navBundle -> The navigation bundle to add to the fragment after the pop occurs
// */
// void dismissFragment(Bundle navBundle);
//
// /**
// * Dismiss all fragments to the given index in the stack
// */
// void dismissToIndex(int index);
//
// /**
// * Dismiss all fragments from the stack until we reach the Root Fragment (the fragment at the min stack size)
// */
// void dismissToRoot();
//
// /**
// * Remove all fragments from the stack including the Root. The add the given {@link Navigation}
// * as the new root fragment. The definition of the Root Fragment is the Fragment at the min stack size position.
// *
// * @param
// * navFragment -> The fragment that you would like as the new Root of the stack.
// */
// void replaceRootFragment(Navigation navFragment);
//
// void setTitle(String title);
// void setTitle(int resId);
// String getTitle();
//
// boolean isPortrait();
// boolean isTablet();
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/Stack.java
// public interface Stack extends Serializable {
//
// Navigation pushFragment(NavigationManager navigationManager, Navigation navFragment, PresentationTransaction transaction);
//
// Navigation popFragment(NavigationManager navigationManager, Bundle navBundle);
//
// void clearNavigationStackToIndex(NavigationManager navigationManager, int index);
//
// void clearNavigationStackToIndex(NavigationManager navigationManager, int index, boolean inclusive);
//
// Navigation getFragmentAtIndex(NavigationManager navigationManager, int index);
//
// }
//
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/interfaces/State.java
// public interface State extends Serializable {
//
// Stack<String> getStack();
//
// void isTablet(boolean isTablet);
//
// boolean isTablet();
//
// void isPortrait(boolean isPortrait);
//
// boolean isPortrait();
// }
// Path: navigation-fragment/src/main/java/com/github/dmcapps/navigationfragment/common/core/StackManager.java
import android.app.FragmentManager;
import android.os.Bundle;
import android.util.Log;
import com.github.dmcapps.navigationfragment.common.interfaces.Navigation;
import com.github.dmcapps.navigationfragment.common.interfaces.Stack;
import com.github.dmcapps.navigationfragment.common.interfaces.State;
import java.util.Locale;
package com.github.dmcapps.navigationfragment.common.core;
/**
* Created by dcarmo on 2016-11-19.
*/
public class StackManager implements Stack {
private static final String TAG = StackManager.class.getSimpleName();
@Override
public Navigation pushFragment(NavigationManager navigationManager, Navigation navFragment, PresentationTransaction transaction) {
NavigationConfig config = navigationManager.getConfig();
if (transaction.getNavBundle() != null) {
navFragment.setNavBundle(transaction.getNavBundle());
}
// Don't animate the initial fragments being added to the stack.
if (navigationManager.getCurrentStackSize() < config.getMinStackSize()) {
transaction.setCustomAnimations(0, 0, 0, 0);
}
// Add in the new fragment that we are presenting and add it's navigation tag to the stack.
transaction.add(config.getPushContainerId(), navFragment, navFragment.getNavTag());
transaction.addToBackStack(navFragment.getNavTag());
transaction.commit();
navigationManager.addToStack(navFragment);
return navFragment;
}
@Override
public Navigation popFragment(NavigationManager navigationManager, Bundle navBundle) {
Navigation navFragment = null;
| State state = navigationManager.getState(); |
garbagemule/MobArena | src/main/java/com/garbagemule/MobArena/SpawnsPets.java | // Path: src/main/java/com/garbagemule/MobArena/framework/Arena.java
// public interface Arena
// {
// /*/////////////////////////////////////////////////////////////////////////
// //
// // NEW METHODS IN REFACTORING
// //
// /////////////////////////////////////////////////////////////////////////*/
//
// ConfigurationSection getSettings();
//
// World getWorld();
//
// void setWorld(World world);
//
// boolean isEnabled();
//
// void setEnabled(boolean value);
//
// boolean isProtected();
//
// void setProtected(boolean value);
//
// boolean isRunning();
//
// boolean inEditMode();
//
// void setEditMode(boolean value);
//
// int getMinPlayers();
//
// int getMaxPlayers();
//
// List<Thing> getEntryFee();
//
// Set<Map.Entry<Integer, ThingPicker>> getEveryWaveEntrySet();
//
// ThingPicker getAfterWaveReward(int wave);
//
// Set<Player> getPlayersInArena();
//
// Set<Player> getPlayersInLobby();
//
// Set<Player> getReadyPlayersInLobby();
//
// Set<Player> getSpectators();
//
// MASpawnThread getSpawnThread();
//
// WaveManager getWaveManager();
//
// ArenaListener getEventListener();
//
// void setLeaderboard(Leaderboard leaderboard);
//
// ArenaPlayer getArenaPlayer(Player p);
//
// Set<Block> getBlocks();
//
// void addBlock(Block b);
//
// boolean removeBlock(Block b);
//
// boolean hasPet(Entity e);
//
// void addRepairable(Repairable r);
//
// ArenaRegion getRegion();
//
// InventoryManager getInventoryManager();
//
// RewardManager getRewardManager();
//
// MonsterManager getMonsterManager();
//
// ClassLimitManager getClassLimitManager();
//
// void revivePlayer(Player p);
//
// ScoreboardManager getScoreboard();
//
//
// Messenger getMessenger();
//
// Messenger getGlobalMessenger();
//
// void announce(String msg);
//
// void announce(Msg msg, String s);
//
// void announce(Msg msg);
//
//
//
//
// void scheduleTask(Runnable r, int delay);
//
//
//
//
//
//
//
//
//
//
//
//
// boolean startArena();
//
// boolean endArena();
//
// void forceStart();
//
// void forceEnd();
//
// boolean hasPermission(Player p);
//
// boolean playerJoin(Player p, Location loc);
//
// void playerReady(Player p);
//
// boolean playerLeave(Player p);
//
// boolean isMoving(Player p);
//
// boolean isLeaving(Player p);
//
// void playerDeath(Player p);
//
// void playerRespawn(Player p);
//
// Location getRespawnLocation(Player p);
//
// void playerSpec(Player p, Location loc);
//
// void storeContainerContents();
//
// void restoreContainerContents();
//
// void discardPlayer(Player p);
//
// void repairBlocks();
//
// void queueRepairable(Repairable r);
//
//
//
// /*////////////////////////////////////////////////////////////////////
// //
// // Items & Cleanup
// //
// ////////////////////////////////////////////////////////////////////*/
//
// void assignClass(Player p, String className);
//
// void assignClassGiveInv(Player p, String className, ItemStack[] contents);
//
// void addRandomPlayer(Player p);
//
// void assignRandomClass(Player p);
//
//
//
// /*////////////////////////////////////////////////////////////////////
// //
// // Initialization & Checks
// //
// ////////////////////////////////////////////////////////////////////*/
//
// void restoreRegion();
//
//
//
// /*////////////////////////////////////////////////////////////////////
// //
// // Getters & Misc
// //
// ////////////////////////////////////////////////////////////////////*/
//
// boolean inArena(Player p);
//
// boolean inLobby(Player p);
//
// boolean inSpec(Player p);
//
// boolean isDead(Player p);
//
// String configName();
//
// /**
// * @deprecated use {@link #configName()} instead
// */
// @Deprecated
// String arenaName();
//
// String getSlug();
//
// MobArena getPlugin();
//
// Map<String,ArenaClass> getClasses();
//
// int getPlayerCount();
//
// List<Player> getAllPlayers();
//
// Collection<ArenaPlayer> getArenaPlayerSet();
//
// List<Player> getNonreadyPlayers();
//
// boolean canAfford(Player p);
//
// boolean takeFee(Player p);
//
// boolean refund(Player p);
//
// boolean canJoin(Player p);
//
// boolean canSpec(Player p);
//
// boolean hasIsolatedChat();
//
// Player getLastPlayerStanding();
//
// AutoStartTimer getAutoStartTimer();
// }
| import com.garbagemule.MobArena.framework.Arena;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable;
import org.bukkit.inventory.PlayerInventory;
import java.util.HashMap;
import java.util.Map; | package com.garbagemule.MobArena;
public class SpawnsPets {
private final Map<Material, EntityType> materialToEntity;
SpawnsPets() {
this.materialToEntity = new HashMap<>();
}
void register(Material material, EntityType entity) {
materialToEntity.put(material, entity);
}
void clear() {
materialToEntity.clear();
}
| // Path: src/main/java/com/garbagemule/MobArena/framework/Arena.java
// public interface Arena
// {
// /*/////////////////////////////////////////////////////////////////////////
// //
// // NEW METHODS IN REFACTORING
// //
// /////////////////////////////////////////////////////////////////////////*/
//
// ConfigurationSection getSettings();
//
// World getWorld();
//
// void setWorld(World world);
//
// boolean isEnabled();
//
// void setEnabled(boolean value);
//
// boolean isProtected();
//
// void setProtected(boolean value);
//
// boolean isRunning();
//
// boolean inEditMode();
//
// void setEditMode(boolean value);
//
// int getMinPlayers();
//
// int getMaxPlayers();
//
// List<Thing> getEntryFee();
//
// Set<Map.Entry<Integer, ThingPicker>> getEveryWaveEntrySet();
//
// ThingPicker getAfterWaveReward(int wave);
//
// Set<Player> getPlayersInArena();
//
// Set<Player> getPlayersInLobby();
//
// Set<Player> getReadyPlayersInLobby();
//
// Set<Player> getSpectators();
//
// MASpawnThread getSpawnThread();
//
// WaveManager getWaveManager();
//
// ArenaListener getEventListener();
//
// void setLeaderboard(Leaderboard leaderboard);
//
// ArenaPlayer getArenaPlayer(Player p);
//
// Set<Block> getBlocks();
//
// void addBlock(Block b);
//
// boolean removeBlock(Block b);
//
// boolean hasPet(Entity e);
//
// void addRepairable(Repairable r);
//
// ArenaRegion getRegion();
//
// InventoryManager getInventoryManager();
//
// RewardManager getRewardManager();
//
// MonsterManager getMonsterManager();
//
// ClassLimitManager getClassLimitManager();
//
// void revivePlayer(Player p);
//
// ScoreboardManager getScoreboard();
//
//
// Messenger getMessenger();
//
// Messenger getGlobalMessenger();
//
// void announce(String msg);
//
// void announce(Msg msg, String s);
//
// void announce(Msg msg);
//
//
//
//
// void scheduleTask(Runnable r, int delay);
//
//
//
//
//
//
//
//
//
//
//
//
// boolean startArena();
//
// boolean endArena();
//
// void forceStart();
//
// void forceEnd();
//
// boolean hasPermission(Player p);
//
// boolean playerJoin(Player p, Location loc);
//
// void playerReady(Player p);
//
// boolean playerLeave(Player p);
//
// boolean isMoving(Player p);
//
// boolean isLeaving(Player p);
//
// void playerDeath(Player p);
//
// void playerRespawn(Player p);
//
// Location getRespawnLocation(Player p);
//
// void playerSpec(Player p, Location loc);
//
// void storeContainerContents();
//
// void restoreContainerContents();
//
// void discardPlayer(Player p);
//
// void repairBlocks();
//
// void queueRepairable(Repairable r);
//
//
//
// /*////////////////////////////////////////////////////////////////////
// //
// // Items & Cleanup
// //
// ////////////////////////////////////////////////////////////////////*/
//
// void assignClass(Player p, String className);
//
// void assignClassGiveInv(Player p, String className, ItemStack[] contents);
//
// void addRandomPlayer(Player p);
//
// void assignRandomClass(Player p);
//
//
//
// /*////////////////////////////////////////////////////////////////////
// //
// // Initialization & Checks
// //
// ////////////////////////////////////////////////////////////////////*/
//
// void restoreRegion();
//
//
//
// /*////////////////////////////////////////////////////////////////////
// //
// // Getters & Misc
// //
// ////////////////////////////////////////////////////////////////////*/
//
// boolean inArena(Player p);
//
// boolean inLobby(Player p);
//
// boolean inSpec(Player p);
//
// boolean isDead(Player p);
//
// String configName();
//
// /**
// * @deprecated use {@link #configName()} instead
// */
// @Deprecated
// String arenaName();
//
// String getSlug();
//
// MobArena getPlugin();
//
// Map<String,ArenaClass> getClasses();
//
// int getPlayerCount();
//
// List<Player> getAllPlayers();
//
// Collection<ArenaPlayer> getArenaPlayerSet();
//
// List<Player> getNonreadyPlayers();
//
// boolean canAfford(Player p);
//
// boolean takeFee(Player p);
//
// boolean refund(Player p);
//
// boolean canJoin(Player p);
//
// boolean canSpec(Player p);
//
// boolean hasIsolatedChat();
//
// Player getLastPlayerStanding();
//
// AutoStartTimer getAutoStartTimer();
// }
// Path: src/main/java/com/garbagemule/MobArena/SpawnsPets.java
import com.garbagemule.MobArena.framework.Arena;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable;
import org.bukkit.inventory.PlayerInventory;
import java.util.HashMap;
import java.util.Map;
package com.garbagemule.MobArena;
public class SpawnsPets {
private final Map<Material, EntityType> materialToEntity;
SpawnsPets() {
this.materialToEntity = new HashMap<>();
}
void register(Material material, EntityType entity) {
materialToEntity.put(material, entity);
}
void clear() {
materialToEntity.clear();
}
| void spawn(Arena arena) { |
garbagemule/MobArena | src/main/java/com/garbagemule/MobArena/waves/ability/core/DisorientAll.java | // Path: src/main/java/com/garbagemule/MobArena/framework/Arena.java
// public interface Arena
// {
// /*/////////////////////////////////////////////////////////////////////////
// //
// // NEW METHODS IN REFACTORING
// //
// /////////////////////////////////////////////////////////////////////////*/
//
// ConfigurationSection getSettings();
//
// World getWorld();
//
// void setWorld(World world);
//
// boolean isEnabled();
//
// void setEnabled(boolean value);
//
// boolean isProtected();
//
// void setProtected(boolean value);
//
// boolean isRunning();
//
// boolean inEditMode();
//
// void setEditMode(boolean value);
//
// int getMinPlayers();
//
// int getMaxPlayers();
//
// List<Thing> getEntryFee();
//
// Set<Map.Entry<Integer, ThingPicker>> getEveryWaveEntrySet();
//
// ThingPicker getAfterWaveReward(int wave);
//
// Set<Player> getPlayersInArena();
//
// Set<Player> getPlayersInLobby();
//
// Set<Player> getReadyPlayersInLobby();
//
// Set<Player> getSpectators();
//
// MASpawnThread getSpawnThread();
//
// WaveManager getWaveManager();
//
// ArenaListener getEventListener();
//
// void setLeaderboard(Leaderboard leaderboard);
//
// ArenaPlayer getArenaPlayer(Player p);
//
// Set<Block> getBlocks();
//
// void addBlock(Block b);
//
// boolean removeBlock(Block b);
//
// boolean hasPet(Entity e);
//
// void addRepairable(Repairable r);
//
// ArenaRegion getRegion();
//
// InventoryManager getInventoryManager();
//
// RewardManager getRewardManager();
//
// MonsterManager getMonsterManager();
//
// ClassLimitManager getClassLimitManager();
//
// void revivePlayer(Player p);
//
// ScoreboardManager getScoreboard();
//
//
// Messenger getMessenger();
//
// Messenger getGlobalMessenger();
//
// void announce(String msg);
//
// void announce(Msg msg, String s);
//
// void announce(Msg msg);
//
//
//
//
// void scheduleTask(Runnable r, int delay);
//
//
//
//
//
//
//
//
//
//
//
//
// boolean startArena();
//
// boolean endArena();
//
// void forceStart();
//
// void forceEnd();
//
// boolean hasPermission(Player p);
//
// boolean playerJoin(Player p, Location loc);
//
// void playerReady(Player p);
//
// boolean playerLeave(Player p);
//
// boolean isMoving(Player p);
//
// boolean isLeaving(Player p);
//
// void playerDeath(Player p);
//
// void playerRespawn(Player p);
//
// Location getRespawnLocation(Player p);
//
// void playerSpec(Player p, Location loc);
//
// void storeContainerContents();
//
// void restoreContainerContents();
//
// void discardPlayer(Player p);
//
// void repairBlocks();
//
// void queueRepairable(Repairable r);
//
//
//
// /*////////////////////////////////////////////////////////////////////
// //
// // Items & Cleanup
// //
// ////////////////////////////////////////////////////////////////////*/
//
// void assignClass(Player p, String className);
//
// void assignClassGiveInv(Player p, String className, ItemStack[] contents);
//
// void addRandomPlayer(Player p);
//
// void assignRandomClass(Player p);
//
//
//
// /*////////////////////////////////////////////////////////////////////
// //
// // Initialization & Checks
// //
// ////////////////////////////////////////////////////////////////////*/
//
// void restoreRegion();
//
//
//
// /*////////////////////////////////////////////////////////////////////
// //
// // Getters & Misc
// //
// ////////////////////////////////////////////////////////////////////*/
//
// boolean inArena(Player p);
//
// boolean inLobby(Player p);
//
// boolean inSpec(Player p);
//
// boolean isDead(Player p);
//
// String configName();
//
// /**
// * @deprecated use {@link #configName()} instead
// */
// @Deprecated
// String arenaName();
//
// String getSlug();
//
// MobArena getPlugin();
//
// Map<String,ArenaClass> getClasses();
//
// int getPlayerCount();
//
// List<Player> getAllPlayers();
//
// Collection<ArenaPlayer> getArenaPlayerSet();
//
// List<Player> getNonreadyPlayers();
//
// boolean canAfford(Player p);
//
// boolean takeFee(Player p);
//
// boolean refund(Player p);
//
// boolean canJoin(Player p);
//
// boolean canSpec(Player p);
//
// boolean hasIsolatedChat();
//
// Player getLastPlayerStanding();
//
// AutoStartTimer getAutoStartTimer();
// }
| import com.garbagemule.MobArena.framework.Arena;
import com.garbagemule.MobArena.waves.MABoss;
import com.garbagemule.MobArena.waves.ability.Ability;
import com.garbagemule.MobArena.waves.ability.AbilityInfo;
import com.garbagemule.MobArena.waves.ability.AbilityUtils;
import org.bukkit.Location;
import org.bukkit.entity.Player; | package com.garbagemule.MobArena.waves.ability.core;
@AbilityInfo(
name = "Disorient All",
aliases = {"disorientall"}
)
public class DisorientAll implements Ability
{
@Override | // Path: src/main/java/com/garbagemule/MobArena/framework/Arena.java
// public interface Arena
// {
// /*/////////////////////////////////////////////////////////////////////////
// //
// // NEW METHODS IN REFACTORING
// //
// /////////////////////////////////////////////////////////////////////////*/
//
// ConfigurationSection getSettings();
//
// World getWorld();
//
// void setWorld(World world);
//
// boolean isEnabled();
//
// void setEnabled(boolean value);
//
// boolean isProtected();
//
// void setProtected(boolean value);
//
// boolean isRunning();
//
// boolean inEditMode();
//
// void setEditMode(boolean value);
//
// int getMinPlayers();
//
// int getMaxPlayers();
//
// List<Thing> getEntryFee();
//
// Set<Map.Entry<Integer, ThingPicker>> getEveryWaveEntrySet();
//
// ThingPicker getAfterWaveReward(int wave);
//
// Set<Player> getPlayersInArena();
//
// Set<Player> getPlayersInLobby();
//
// Set<Player> getReadyPlayersInLobby();
//
// Set<Player> getSpectators();
//
// MASpawnThread getSpawnThread();
//
// WaveManager getWaveManager();
//
// ArenaListener getEventListener();
//
// void setLeaderboard(Leaderboard leaderboard);
//
// ArenaPlayer getArenaPlayer(Player p);
//
// Set<Block> getBlocks();
//
// void addBlock(Block b);
//
// boolean removeBlock(Block b);
//
// boolean hasPet(Entity e);
//
// void addRepairable(Repairable r);
//
// ArenaRegion getRegion();
//
// InventoryManager getInventoryManager();
//
// RewardManager getRewardManager();
//
// MonsterManager getMonsterManager();
//
// ClassLimitManager getClassLimitManager();
//
// void revivePlayer(Player p);
//
// ScoreboardManager getScoreboard();
//
//
// Messenger getMessenger();
//
// Messenger getGlobalMessenger();
//
// void announce(String msg);
//
// void announce(Msg msg, String s);
//
// void announce(Msg msg);
//
//
//
//
// void scheduleTask(Runnable r, int delay);
//
//
//
//
//
//
//
//
//
//
//
//
// boolean startArena();
//
// boolean endArena();
//
// void forceStart();
//
// void forceEnd();
//
// boolean hasPermission(Player p);
//
// boolean playerJoin(Player p, Location loc);
//
// void playerReady(Player p);
//
// boolean playerLeave(Player p);
//
// boolean isMoving(Player p);
//
// boolean isLeaving(Player p);
//
// void playerDeath(Player p);
//
// void playerRespawn(Player p);
//
// Location getRespawnLocation(Player p);
//
// void playerSpec(Player p, Location loc);
//
// void storeContainerContents();
//
// void restoreContainerContents();
//
// void discardPlayer(Player p);
//
// void repairBlocks();
//
// void queueRepairable(Repairable r);
//
//
//
// /*////////////////////////////////////////////////////////////////////
// //
// // Items & Cleanup
// //
// ////////////////////////////////////////////////////////////////////*/
//
// void assignClass(Player p, String className);
//
// void assignClassGiveInv(Player p, String className, ItemStack[] contents);
//
// void addRandomPlayer(Player p);
//
// void assignRandomClass(Player p);
//
//
//
// /*////////////////////////////////////////////////////////////////////
// //
// // Initialization & Checks
// //
// ////////////////////////////////////////////////////////////////////*/
//
// void restoreRegion();
//
//
//
// /*////////////////////////////////////////////////////////////////////
// //
// // Getters & Misc
// //
// ////////////////////////////////////////////////////////////////////*/
//
// boolean inArena(Player p);
//
// boolean inLobby(Player p);
//
// boolean inSpec(Player p);
//
// boolean isDead(Player p);
//
// String configName();
//
// /**
// * @deprecated use {@link #configName()} instead
// */
// @Deprecated
// String arenaName();
//
// String getSlug();
//
// MobArena getPlugin();
//
// Map<String,ArenaClass> getClasses();
//
// int getPlayerCount();
//
// List<Player> getAllPlayers();
//
// Collection<ArenaPlayer> getArenaPlayerSet();
//
// List<Player> getNonreadyPlayers();
//
// boolean canAfford(Player p);
//
// boolean takeFee(Player p);
//
// boolean refund(Player p);
//
// boolean canJoin(Player p);
//
// boolean canSpec(Player p);
//
// boolean hasIsolatedChat();
//
// Player getLastPlayerStanding();
//
// AutoStartTimer getAutoStartTimer();
// }
// Path: src/main/java/com/garbagemule/MobArena/waves/ability/core/DisorientAll.java
import com.garbagemule.MobArena.framework.Arena;
import com.garbagemule.MobArena.waves.MABoss;
import com.garbagemule.MobArena.waves.ability.Ability;
import com.garbagemule.MobArena.waves.ability.AbilityInfo;
import com.garbagemule.MobArena.waves.ability.AbilityUtils;
import org.bukkit.Location;
import org.bukkit.entity.Player;
package com.garbagemule.MobArena.waves.ability.core;
@AbilityInfo(
name = "Disorient All",
aliases = {"disorientall"}
)
public class DisorientAll implements Ability
{
@Override | public void execute(Arena arena, MABoss boss) { |
garbagemule/MobArena | src/main/java/com/garbagemule/MobArena/waves/ability/AbilityManager.java | // Path: src/main/java/com/garbagemule/MobArena/waves/ability/core/DisorientAll.java
// @AbilityInfo(
// name = "Disorient All",
// aliases = {"disorientall"}
// )
// public class DisorientAll implements Ability
// {
// @Override
// public void execute(Arena arena, MABoss boss) {
// for (Player p : arena.getPlayersInArena()) {
// Location loc = p.getLocation();
// loc.setYaw(loc.getYaw() + 45 + AbilityUtils.random.nextInt(270));
// p.teleport(loc);
// }
// }
// }
//
// Path: src/main/java/com/garbagemule/MobArena/waves/ability/core/FetchAll.java
// @AbilityInfo(
// name = "Fetch All",
// aliases = {"fetchall"}
// )
// public class FetchAll implements Ability
// {
// @Override
// public void execute(Arena arena, MABoss boss) {
// Location bLoc = boss.getEntity().getLocation();
//
// for (Player p : arena.getPlayersInArena()) {
// p.teleport(bLoc);
// }
// }
// }
//
// Path: src/main/java/com/garbagemule/MobArena/waves/ability/core/PullAll.java
// @AbilityInfo(
// name = "Pull All",
// aliases = {"pullall"}
// )
// public class PullAll implements Ability
// {
// @Override
// public void execute(Arena arena, MABoss boss) {
// Location bLoc = boss.getEntity().getLocation();
//
// for (Player p : arena.getPlayersInArena()) {
// Location loc = p.getLocation();
// Vector v = new Vector(bLoc.getX() - loc.getX(), 0, bLoc.getZ() - loc.getZ());
//
// double a = Math.abs(bLoc.getX() - loc.getX());
// double b = Math.abs(bLoc.getZ() - loc.getZ());
// double c = Math.sqrt((a*a + b*b));
//
// p.setVelocity(v.normalize().multiply(c*0.3).setY(0.8));
// }
// }
// }
//
// Path: src/main/java/com/garbagemule/MobArena/waves/ability/core/ThrowAll.java
// @AbilityInfo(
// name = "Throw All",
// aliases = {"throwall"}
// )
// public class ThrowAll implements Ability
// {
// @Override
// public void execute(Arena arena, MABoss boss) {
// Location bLoc = boss.getEntity().getLocation();
//
// for (Player p : arena.getPlayersInArena()) {
// Location loc = p.getLocation();
// Vector v = new Vector(loc.getX() - bLoc.getX(), 0, loc.getZ() - bLoc.getZ());
// p.setVelocity(v.normalize().setY(0.8));
// }
// }
// }
| import com.garbagemule.MobArena.waves.ability.core.ChainLightning;
import com.garbagemule.MobArena.waves.ability.core.DisorientAll;
import com.garbagemule.MobArena.waves.ability.core.DisorientDistant;
import com.garbagemule.MobArena.waves.ability.core.DisorientNearby;
import com.garbagemule.MobArena.waves.ability.core.DisorientTarget;
import com.garbagemule.MobArena.waves.ability.core.FetchAll;
import com.garbagemule.MobArena.waves.ability.core.FetchDistant;
import com.garbagemule.MobArena.waves.ability.core.FetchNearby;
import com.garbagemule.MobArena.waves.ability.core.FetchTarget;
import com.garbagemule.MobArena.waves.ability.core.FireAura;
import com.garbagemule.MobArena.waves.ability.core.Flood;
import com.garbagemule.MobArena.waves.ability.core.LightningAura;
import com.garbagemule.MobArena.waves.ability.core.LivingBomb;
import com.garbagemule.MobArena.waves.ability.core.ObsidianBomb;
import com.garbagemule.MobArena.waves.ability.core.PullAll;
import com.garbagemule.MobArena.waves.ability.core.PullDistant;
import com.garbagemule.MobArena.waves.ability.core.PullNearby;
import com.garbagemule.MobArena.waves.ability.core.PullTarget;
import com.garbagemule.MobArena.waves.ability.core.RootTarget;
import com.garbagemule.MobArena.waves.ability.core.ShootArrow;
import com.garbagemule.MobArena.waves.ability.core.ShootFireball;
import com.garbagemule.MobArena.waves.ability.core.ShufflePositions;
import com.garbagemule.MobArena.waves.ability.core.ThrowAll;
import com.garbagemule.MobArena.waves.ability.core.ThrowDistant;
import com.garbagemule.MobArena.waves.ability.core.ThrowNearby;
import com.garbagemule.MobArena.waves.ability.core.ThrowTarget;
import com.garbagemule.MobArena.waves.ability.core.WarpToPlayer;
import org.bukkit.Bukkit;
import javax.tools.JavaCompiler;
import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;
import javax.tools.ToolProvider;
import java.io.File;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map; | package com.garbagemule.MobArena.waves.ability;
public class AbilityManager
{
private static final String ma = "plugins" + File.separator + "MobArena.jar";
private static final String cb = System.getProperty("java.class.path");
private static final String classpath = ma + System.getProperty("path.separator") + cb;
private static Map<String,Class<? extends Ability>> abilities;
/**
* Get an instance of an ability by alias
* @param alias the alias of an ability
* @return a new Ability object, or null
*/
public static Ability getAbility(String alias) {
try {
Class<? extends Ability> cls = abilities.get(alias.toLowerCase().replaceAll("[-_.]", ""));
return cls.newInstance();
} catch (Exception e) {
return null;
}
}
/**
* Load all the core abilities included in MobArena
*/
public static void loadCoreAbilities() {
if (abilities == null) abilities = new HashMap<>();
register(ChainLightning.class); | // Path: src/main/java/com/garbagemule/MobArena/waves/ability/core/DisorientAll.java
// @AbilityInfo(
// name = "Disorient All",
// aliases = {"disorientall"}
// )
// public class DisorientAll implements Ability
// {
// @Override
// public void execute(Arena arena, MABoss boss) {
// for (Player p : arena.getPlayersInArena()) {
// Location loc = p.getLocation();
// loc.setYaw(loc.getYaw() + 45 + AbilityUtils.random.nextInt(270));
// p.teleport(loc);
// }
// }
// }
//
// Path: src/main/java/com/garbagemule/MobArena/waves/ability/core/FetchAll.java
// @AbilityInfo(
// name = "Fetch All",
// aliases = {"fetchall"}
// )
// public class FetchAll implements Ability
// {
// @Override
// public void execute(Arena arena, MABoss boss) {
// Location bLoc = boss.getEntity().getLocation();
//
// for (Player p : arena.getPlayersInArena()) {
// p.teleport(bLoc);
// }
// }
// }
//
// Path: src/main/java/com/garbagemule/MobArena/waves/ability/core/PullAll.java
// @AbilityInfo(
// name = "Pull All",
// aliases = {"pullall"}
// )
// public class PullAll implements Ability
// {
// @Override
// public void execute(Arena arena, MABoss boss) {
// Location bLoc = boss.getEntity().getLocation();
//
// for (Player p : arena.getPlayersInArena()) {
// Location loc = p.getLocation();
// Vector v = new Vector(bLoc.getX() - loc.getX(), 0, bLoc.getZ() - loc.getZ());
//
// double a = Math.abs(bLoc.getX() - loc.getX());
// double b = Math.abs(bLoc.getZ() - loc.getZ());
// double c = Math.sqrt((a*a + b*b));
//
// p.setVelocity(v.normalize().multiply(c*0.3).setY(0.8));
// }
// }
// }
//
// Path: src/main/java/com/garbagemule/MobArena/waves/ability/core/ThrowAll.java
// @AbilityInfo(
// name = "Throw All",
// aliases = {"throwall"}
// )
// public class ThrowAll implements Ability
// {
// @Override
// public void execute(Arena arena, MABoss boss) {
// Location bLoc = boss.getEntity().getLocation();
//
// for (Player p : arena.getPlayersInArena()) {
// Location loc = p.getLocation();
// Vector v = new Vector(loc.getX() - bLoc.getX(), 0, loc.getZ() - bLoc.getZ());
// p.setVelocity(v.normalize().setY(0.8));
// }
// }
// }
// Path: src/main/java/com/garbagemule/MobArena/waves/ability/AbilityManager.java
import com.garbagemule.MobArena.waves.ability.core.ChainLightning;
import com.garbagemule.MobArena.waves.ability.core.DisorientAll;
import com.garbagemule.MobArena.waves.ability.core.DisorientDistant;
import com.garbagemule.MobArena.waves.ability.core.DisorientNearby;
import com.garbagemule.MobArena.waves.ability.core.DisorientTarget;
import com.garbagemule.MobArena.waves.ability.core.FetchAll;
import com.garbagemule.MobArena.waves.ability.core.FetchDistant;
import com.garbagemule.MobArena.waves.ability.core.FetchNearby;
import com.garbagemule.MobArena.waves.ability.core.FetchTarget;
import com.garbagemule.MobArena.waves.ability.core.FireAura;
import com.garbagemule.MobArena.waves.ability.core.Flood;
import com.garbagemule.MobArena.waves.ability.core.LightningAura;
import com.garbagemule.MobArena.waves.ability.core.LivingBomb;
import com.garbagemule.MobArena.waves.ability.core.ObsidianBomb;
import com.garbagemule.MobArena.waves.ability.core.PullAll;
import com.garbagemule.MobArena.waves.ability.core.PullDistant;
import com.garbagemule.MobArena.waves.ability.core.PullNearby;
import com.garbagemule.MobArena.waves.ability.core.PullTarget;
import com.garbagemule.MobArena.waves.ability.core.RootTarget;
import com.garbagemule.MobArena.waves.ability.core.ShootArrow;
import com.garbagemule.MobArena.waves.ability.core.ShootFireball;
import com.garbagemule.MobArena.waves.ability.core.ShufflePositions;
import com.garbagemule.MobArena.waves.ability.core.ThrowAll;
import com.garbagemule.MobArena.waves.ability.core.ThrowDistant;
import com.garbagemule.MobArena.waves.ability.core.ThrowNearby;
import com.garbagemule.MobArena.waves.ability.core.ThrowTarget;
import com.garbagemule.MobArena.waves.ability.core.WarpToPlayer;
import org.bukkit.Bukkit;
import javax.tools.JavaCompiler;
import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;
import javax.tools.ToolProvider;
import java.io.File;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
package com.garbagemule.MobArena.waves.ability;
public class AbilityManager
{
private static final String ma = "plugins" + File.separator + "MobArena.jar";
private static final String cb = System.getProperty("java.class.path");
private static final String classpath = ma + System.getProperty("path.separator") + cb;
private static Map<String,Class<? extends Ability>> abilities;
/**
* Get an instance of an ability by alias
* @param alias the alias of an ability
* @return a new Ability object, or null
*/
public static Ability getAbility(String alias) {
try {
Class<? extends Ability> cls = abilities.get(alias.toLowerCase().replaceAll("[-_.]", ""));
return cls.newInstance();
} catch (Exception e) {
return null;
}
}
/**
* Load all the core abilities included in MobArena
*/
public static void loadCoreAbilities() {
if (abilities == null) abilities = new HashMap<>();
register(ChainLightning.class); | register(DisorientAll.class); |
garbagemule/MobArena | src/main/java/com/garbagemule/MobArena/waves/ability/AbilityManager.java | // Path: src/main/java/com/garbagemule/MobArena/waves/ability/core/DisorientAll.java
// @AbilityInfo(
// name = "Disorient All",
// aliases = {"disorientall"}
// )
// public class DisorientAll implements Ability
// {
// @Override
// public void execute(Arena arena, MABoss boss) {
// for (Player p : arena.getPlayersInArena()) {
// Location loc = p.getLocation();
// loc.setYaw(loc.getYaw() + 45 + AbilityUtils.random.nextInt(270));
// p.teleport(loc);
// }
// }
// }
//
// Path: src/main/java/com/garbagemule/MobArena/waves/ability/core/FetchAll.java
// @AbilityInfo(
// name = "Fetch All",
// aliases = {"fetchall"}
// )
// public class FetchAll implements Ability
// {
// @Override
// public void execute(Arena arena, MABoss boss) {
// Location bLoc = boss.getEntity().getLocation();
//
// for (Player p : arena.getPlayersInArena()) {
// p.teleport(bLoc);
// }
// }
// }
//
// Path: src/main/java/com/garbagemule/MobArena/waves/ability/core/PullAll.java
// @AbilityInfo(
// name = "Pull All",
// aliases = {"pullall"}
// )
// public class PullAll implements Ability
// {
// @Override
// public void execute(Arena arena, MABoss boss) {
// Location bLoc = boss.getEntity().getLocation();
//
// for (Player p : arena.getPlayersInArena()) {
// Location loc = p.getLocation();
// Vector v = new Vector(bLoc.getX() - loc.getX(), 0, bLoc.getZ() - loc.getZ());
//
// double a = Math.abs(bLoc.getX() - loc.getX());
// double b = Math.abs(bLoc.getZ() - loc.getZ());
// double c = Math.sqrt((a*a + b*b));
//
// p.setVelocity(v.normalize().multiply(c*0.3).setY(0.8));
// }
// }
// }
//
// Path: src/main/java/com/garbagemule/MobArena/waves/ability/core/ThrowAll.java
// @AbilityInfo(
// name = "Throw All",
// aliases = {"throwall"}
// )
// public class ThrowAll implements Ability
// {
// @Override
// public void execute(Arena arena, MABoss boss) {
// Location bLoc = boss.getEntity().getLocation();
//
// for (Player p : arena.getPlayersInArena()) {
// Location loc = p.getLocation();
// Vector v = new Vector(loc.getX() - bLoc.getX(), 0, loc.getZ() - bLoc.getZ());
// p.setVelocity(v.normalize().setY(0.8));
// }
// }
// }
| import com.garbagemule.MobArena.waves.ability.core.ChainLightning;
import com.garbagemule.MobArena.waves.ability.core.DisorientAll;
import com.garbagemule.MobArena.waves.ability.core.DisorientDistant;
import com.garbagemule.MobArena.waves.ability.core.DisorientNearby;
import com.garbagemule.MobArena.waves.ability.core.DisorientTarget;
import com.garbagemule.MobArena.waves.ability.core.FetchAll;
import com.garbagemule.MobArena.waves.ability.core.FetchDistant;
import com.garbagemule.MobArena.waves.ability.core.FetchNearby;
import com.garbagemule.MobArena.waves.ability.core.FetchTarget;
import com.garbagemule.MobArena.waves.ability.core.FireAura;
import com.garbagemule.MobArena.waves.ability.core.Flood;
import com.garbagemule.MobArena.waves.ability.core.LightningAura;
import com.garbagemule.MobArena.waves.ability.core.LivingBomb;
import com.garbagemule.MobArena.waves.ability.core.ObsidianBomb;
import com.garbagemule.MobArena.waves.ability.core.PullAll;
import com.garbagemule.MobArena.waves.ability.core.PullDistant;
import com.garbagemule.MobArena.waves.ability.core.PullNearby;
import com.garbagemule.MobArena.waves.ability.core.PullTarget;
import com.garbagemule.MobArena.waves.ability.core.RootTarget;
import com.garbagemule.MobArena.waves.ability.core.ShootArrow;
import com.garbagemule.MobArena.waves.ability.core.ShootFireball;
import com.garbagemule.MobArena.waves.ability.core.ShufflePositions;
import com.garbagemule.MobArena.waves.ability.core.ThrowAll;
import com.garbagemule.MobArena.waves.ability.core.ThrowDistant;
import com.garbagemule.MobArena.waves.ability.core.ThrowNearby;
import com.garbagemule.MobArena.waves.ability.core.ThrowTarget;
import com.garbagemule.MobArena.waves.ability.core.WarpToPlayer;
import org.bukkit.Bukkit;
import javax.tools.JavaCompiler;
import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;
import javax.tools.ToolProvider;
import java.io.File;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map; | */
public static Ability getAbility(String alias) {
try {
Class<? extends Ability> cls = abilities.get(alias.toLowerCase().replaceAll("[-_.]", ""));
return cls.newInstance();
} catch (Exception e) {
return null;
}
}
/**
* Load all the core abilities included in MobArena
*/
public static void loadCoreAbilities() {
if (abilities == null) abilities = new HashMap<>();
register(ChainLightning.class);
register(DisorientAll.class);
register(DisorientDistant.class);
register(DisorientNearby.class);
register(DisorientTarget.class);
register(FetchAll.class);
register(FetchDistant.class);
register(FetchNearby.class);
register(FetchTarget.class);
register(FireAura.class);
register(Flood.class);
register(LightningAura.class);
register(LivingBomb.class);
register(ObsidianBomb.class); | // Path: src/main/java/com/garbagemule/MobArena/waves/ability/core/DisorientAll.java
// @AbilityInfo(
// name = "Disorient All",
// aliases = {"disorientall"}
// )
// public class DisorientAll implements Ability
// {
// @Override
// public void execute(Arena arena, MABoss boss) {
// for (Player p : arena.getPlayersInArena()) {
// Location loc = p.getLocation();
// loc.setYaw(loc.getYaw() + 45 + AbilityUtils.random.nextInt(270));
// p.teleport(loc);
// }
// }
// }
//
// Path: src/main/java/com/garbagemule/MobArena/waves/ability/core/FetchAll.java
// @AbilityInfo(
// name = "Fetch All",
// aliases = {"fetchall"}
// )
// public class FetchAll implements Ability
// {
// @Override
// public void execute(Arena arena, MABoss boss) {
// Location bLoc = boss.getEntity().getLocation();
//
// for (Player p : arena.getPlayersInArena()) {
// p.teleport(bLoc);
// }
// }
// }
//
// Path: src/main/java/com/garbagemule/MobArena/waves/ability/core/PullAll.java
// @AbilityInfo(
// name = "Pull All",
// aliases = {"pullall"}
// )
// public class PullAll implements Ability
// {
// @Override
// public void execute(Arena arena, MABoss boss) {
// Location bLoc = boss.getEntity().getLocation();
//
// for (Player p : arena.getPlayersInArena()) {
// Location loc = p.getLocation();
// Vector v = new Vector(bLoc.getX() - loc.getX(), 0, bLoc.getZ() - loc.getZ());
//
// double a = Math.abs(bLoc.getX() - loc.getX());
// double b = Math.abs(bLoc.getZ() - loc.getZ());
// double c = Math.sqrt((a*a + b*b));
//
// p.setVelocity(v.normalize().multiply(c*0.3).setY(0.8));
// }
// }
// }
//
// Path: src/main/java/com/garbagemule/MobArena/waves/ability/core/ThrowAll.java
// @AbilityInfo(
// name = "Throw All",
// aliases = {"throwall"}
// )
// public class ThrowAll implements Ability
// {
// @Override
// public void execute(Arena arena, MABoss boss) {
// Location bLoc = boss.getEntity().getLocation();
//
// for (Player p : arena.getPlayersInArena()) {
// Location loc = p.getLocation();
// Vector v = new Vector(loc.getX() - bLoc.getX(), 0, loc.getZ() - bLoc.getZ());
// p.setVelocity(v.normalize().setY(0.8));
// }
// }
// }
// Path: src/main/java/com/garbagemule/MobArena/waves/ability/AbilityManager.java
import com.garbagemule.MobArena.waves.ability.core.ChainLightning;
import com.garbagemule.MobArena.waves.ability.core.DisorientAll;
import com.garbagemule.MobArena.waves.ability.core.DisorientDistant;
import com.garbagemule.MobArena.waves.ability.core.DisorientNearby;
import com.garbagemule.MobArena.waves.ability.core.DisorientTarget;
import com.garbagemule.MobArena.waves.ability.core.FetchAll;
import com.garbagemule.MobArena.waves.ability.core.FetchDistant;
import com.garbagemule.MobArena.waves.ability.core.FetchNearby;
import com.garbagemule.MobArena.waves.ability.core.FetchTarget;
import com.garbagemule.MobArena.waves.ability.core.FireAura;
import com.garbagemule.MobArena.waves.ability.core.Flood;
import com.garbagemule.MobArena.waves.ability.core.LightningAura;
import com.garbagemule.MobArena.waves.ability.core.LivingBomb;
import com.garbagemule.MobArena.waves.ability.core.ObsidianBomb;
import com.garbagemule.MobArena.waves.ability.core.PullAll;
import com.garbagemule.MobArena.waves.ability.core.PullDistant;
import com.garbagemule.MobArena.waves.ability.core.PullNearby;
import com.garbagemule.MobArena.waves.ability.core.PullTarget;
import com.garbagemule.MobArena.waves.ability.core.RootTarget;
import com.garbagemule.MobArena.waves.ability.core.ShootArrow;
import com.garbagemule.MobArena.waves.ability.core.ShootFireball;
import com.garbagemule.MobArena.waves.ability.core.ShufflePositions;
import com.garbagemule.MobArena.waves.ability.core.ThrowAll;
import com.garbagemule.MobArena.waves.ability.core.ThrowDistant;
import com.garbagemule.MobArena.waves.ability.core.ThrowNearby;
import com.garbagemule.MobArena.waves.ability.core.ThrowTarget;
import com.garbagemule.MobArena.waves.ability.core.WarpToPlayer;
import org.bukkit.Bukkit;
import javax.tools.JavaCompiler;
import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;
import javax.tools.ToolProvider;
import java.io.File;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
*/
public static Ability getAbility(String alias) {
try {
Class<? extends Ability> cls = abilities.get(alias.toLowerCase().replaceAll("[-_.]", ""));
return cls.newInstance();
} catch (Exception e) {
return null;
}
}
/**
* Load all the core abilities included in MobArena
*/
public static void loadCoreAbilities() {
if (abilities == null) abilities = new HashMap<>();
register(ChainLightning.class);
register(DisorientAll.class);
register(DisorientDistant.class);
register(DisorientNearby.class);
register(DisorientTarget.class);
register(FetchAll.class);
register(FetchDistant.class);
register(FetchNearby.class);
register(FetchTarget.class);
register(FireAura.class);
register(Flood.class);
register(LightningAura.class);
register(LivingBomb.class);
register(ObsidianBomb.class); | register(PullAll.class); |
garbagemule/MobArena | src/main/java/com/garbagemule/MobArena/waves/ability/AbilityManager.java | // Path: src/main/java/com/garbagemule/MobArena/waves/ability/core/DisorientAll.java
// @AbilityInfo(
// name = "Disorient All",
// aliases = {"disorientall"}
// )
// public class DisorientAll implements Ability
// {
// @Override
// public void execute(Arena arena, MABoss boss) {
// for (Player p : arena.getPlayersInArena()) {
// Location loc = p.getLocation();
// loc.setYaw(loc.getYaw() + 45 + AbilityUtils.random.nextInt(270));
// p.teleport(loc);
// }
// }
// }
//
// Path: src/main/java/com/garbagemule/MobArena/waves/ability/core/FetchAll.java
// @AbilityInfo(
// name = "Fetch All",
// aliases = {"fetchall"}
// )
// public class FetchAll implements Ability
// {
// @Override
// public void execute(Arena arena, MABoss boss) {
// Location bLoc = boss.getEntity().getLocation();
//
// for (Player p : arena.getPlayersInArena()) {
// p.teleport(bLoc);
// }
// }
// }
//
// Path: src/main/java/com/garbagemule/MobArena/waves/ability/core/PullAll.java
// @AbilityInfo(
// name = "Pull All",
// aliases = {"pullall"}
// )
// public class PullAll implements Ability
// {
// @Override
// public void execute(Arena arena, MABoss boss) {
// Location bLoc = boss.getEntity().getLocation();
//
// for (Player p : arena.getPlayersInArena()) {
// Location loc = p.getLocation();
// Vector v = new Vector(bLoc.getX() - loc.getX(), 0, bLoc.getZ() - loc.getZ());
//
// double a = Math.abs(bLoc.getX() - loc.getX());
// double b = Math.abs(bLoc.getZ() - loc.getZ());
// double c = Math.sqrt((a*a + b*b));
//
// p.setVelocity(v.normalize().multiply(c*0.3).setY(0.8));
// }
// }
// }
//
// Path: src/main/java/com/garbagemule/MobArena/waves/ability/core/ThrowAll.java
// @AbilityInfo(
// name = "Throw All",
// aliases = {"throwall"}
// )
// public class ThrowAll implements Ability
// {
// @Override
// public void execute(Arena arena, MABoss boss) {
// Location bLoc = boss.getEntity().getLocation();
//
// for (Player p : arena.getPlayersInArena()) {
// Location loc = p.getLocation();
// Vector v = new Vector(loc.getX() - bLoc.getX(), 0, loc.getZ() - bLoc.getZ());
// p.setVelocity(v.normalize().setY(0.8));
// }
// }
// }
| import com.garbagemule.MobArena.waves.ability.core.ChainLightning;
import com.garbagemule.MobArena.waves.ability.core.DisorientAll;
import com.garbagemule.MobArena.waves.ability.core.DisorientDistant;
import com.garbagemule.MobArena.waves.ability.core.DisorientNearby;
import com.garbagemule.MobArena.waves.ability.core.DisorientTarget;
import com.garbagemule.MobArena.waves.ability.core.FetchAll;
import com.garbagemule.MobArena.waves.ability.core.FetchDistant;
import com.garbagemule.MobArena.waves.ability.core.FetchNearby;
import com.garbagemule.MobArena.waves.ability.core.FetchTarget;
import com.garbagemule.MobArena.waves.ability.core.FireAura;
import com.garbagemule.MobArena.waves.ability.core.Flood;
import com.garbagemule.MobArena.waves.ability.core.LightningAura;
import com.garbagemule.MobArena.waves.ability.core.LivingBomb;
import com.garbagemule.MobArena.waves.ability.core.ObsidianBomb;
import com.garbagemule.MobArena.waves.ability.core.PullAll;
import com.garbagemule.MobArena.waves.ability.core.PullDistant;
import com.garbagemule.MobArena.waves.ability.core.PullNearby;
import com.garbagemule.MobArena.waves.ability.core.PullTarget;
import com.garbagemule.MobArena.waves.ability.core.RootTarget;
import com.garbagemule.MobArena.waves.ability.core.ShootArrow;
import com.garbagemule.MobArena.waves.ability.core.ShootFireball;
import com.garbagemule.MobArena.waves.ability.core.ShufflePositions;
import com.garbagemule.MobArena.waves.ability.core.ThrowAll;
import com.garbagemule.MobArena.waves.ability.core.ThrowDistant;
import com.garbagemule.MobArena.waves.ability.core.ThrowNearby;
import com.garbagemule.MobArena.waves.ability.core.ThrowTarget;
import com.garbagemule.MobArena.waves.ability.core.WarpToPlayer;
import org.bukkit.Bukkit;
import javax.tools.JavaCompiler;
import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;
import javax.tools.ToolProvider;
import java.io.File;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map; | }
/**
* Load all the core abilities included in MobArena
*/
public static void loadCoreAbilities() {
if (abilities == null) abilities = new HashMap<>();
register(ChainLightning.class);
register(DisorientAll.class);
register(DisorientDistant.class);
register(DisorientNearby.class);
register(DisorientTarget.class);
register(FetchAll.class);
register(FetchDistant.class);
register(FetchNearby.class);
register(FetchTarget.class);
register(FireAura.class);
register(Flood.class);
register(LightningAura.class);
register(LivingBomb.class);
register(ObsidianBomb.class);
register(PullAll.class);
register(PullDistant.class);
register(PullNearby.class);
register(PullTarget.class);
register(RootTarget.class);
register(ShootArrow.class);
register(ShootFireball.class);
register(ShufflePositions.class); | // Path: src/main/java/com/garbagemule/MobArena/waves/ability/core/DisorientAll.java
// @AbilityInfo(
// name = "Disorient All",
// aliases = {"disorientall"}
// )
// public class DisorientAll implements Ability
// {
// @Override
// public void execute(Arena arena, MABoss boss) {
// for (Player p : arena.getPlayersInArena()) {
// Location loc = p.getLocation();
// loc.setYaw(loc.getYaw() + 45 + AbilityUtils.random.nextInt(270));
// p.teleport(loc);
// }
// }
// }
//
// Path: src/main/java/com/garbagemule/MobArena/waves/ability/core/FetchAll.java
// @AbilityInfo(
// name = "Fetch All",
// aliases = {"fetchall"}
// )
// public class FetchAll implements Ability
// {
// @Override
// public void execute(Arena arena, MABoss boss) {
// Location bLoc = boss.getEntity().getLocation();
//
// for (Player p : arena.getPlayersInArena()) {
// p.teleport(bLoc);
// }
// }
// }
//
// Path: src/main/java/com/garbagemule/MobArena/waves/ability/core/PullAll.java
// @AbilityInfo(
// name = "Pull All",
// aliases = {"pullall"}
// )
// public class PullAll implements Ability
// {
// @Override
// public void execute(Arena arena, MABoss boss) {
// Location bLoc = boss.getEntity().getLocation();
//
// for (Player p : arena.getPlayersInArena()) {
// Location loc = p.getLocation();
// Vector v = new Vector(bLoc.getX() - loc.getX(), 0, bLoc.getZ() - loc.getZ());
//
// double a = Math.abs(bLoc.getX() - loc.getX());
// double b = Math.abs(bLoc.getZ() - loc.getZ());
// double c = Math.sqrt((a*a + b*b));
//
// p.setVelocity(v.normalize().multiply(c*0.3).setY(0.8));
// }
// }
// }
//
// Path: src/main/java/com/garbagemule/MobArena/waves/ability/core/ThrowAll.java
// @AbilityInfo(
// name = "Throw All",
// aliases = {"throwall"}
// )
// public class ThrowAll implements Ability
// {
// @Override
// public void execute(Arena arena, MABoss boss) {
// Location bLoc = boss.getEntity().getLocation();
//
// for (Player p : arena.getPlayersInArena()) {
// Location loc = p.getLocation();
// Vector v = new Vector(loc.getX() - bLoc.getX(), 0, loc.getZ() - bLoc.getZ());
// p.setVelocity(v.normalize().setY(0.8));
// }
// }
// }
// Path: src/main/java/com/garbagemule/MobArena/waves/ability/AbilityManager.java
import com.garbagemule.MobArena.waves.ability.core.ChainLightning;
import com.garbagemule.MobArena.waves.ability.core.DisorientAll;
import com.garbagemule.MobArena.waves.ability.core.DisorientDistant;
import com.garbagemule.MobArena.waves.ability.core.DisorientNearby;
import com.garbagemule.MobArena.waves.ability.core.DisorientTarget;
import com.garbagemule.MobArena.waves.ability.core.FetchAll;
import com.garbagemule.MobArena.waves.ability.core.FetchDistant;
import com.garbagemule.MobArena.waves.ability.core.FetchNearby;
import com.garbagemule.MobArena.waves.ability.core.FetchTarget;
import com.garbagemule.MobArena.waves.ability.core.FireAura;
import com.garbagemule.MobArena.waves.ability.core.Flood;
import com.garbagemule.MobArena.waves.ability.core.LightningAura;
import com.garbagemule.MobArena.waves.ability.core.LivingBomb;
import com.garbagemule.MobArena.waves.ability.core.ObsidianBomb;
import com.garbagemule.MobArena.waves.ability.core.PullAll;
import com.garbagemule.MobArena.waves.ability.core.PullDistant;
import com.garbagemule.MobArena.waves.ability.core.PullNearby;
import com.garbagemule.MobArena.waves.ability.core.PullTarget;
import com.garbagemule.MobArena.waves.ability.core.RootTarget;
import com.garbagemule.MobArena.waves.ability.core.ShootArrow;
import com.garbagemule.MobArena.waves.ability.core.ShootFireball;
import com.garbagemule.MobArena.waves.ability.core.ShufflePositions;
import com.garbagemule.MobArena.waves.ability.core.ThrowAll;
import com.garbagemule.MobArena.waves.ability.core.ThrowDistant;
import com.garbagemule.MobArena.waves.ability.core.ThrowNearby;
import com.garbagemule.MobArena.waves.ability.core.ThrowTarget;
import com.garbagemule.MobArena.waves.ability.core.WarpToPlayer;
import org.bukkit.Bukkit;
import javax.tools.JavaCompiler;
import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;
import javax.tools.ToolProvider;
import java.io.File;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
}
/**
* Load all the core abilities included in MobArena
*/
public static void loadCoreAbilities() {
if (abilities == null) abilities = new HashMap<>();
register(ChainLightning.class);
register(DisorientAll.class);
register(DisorientDistant.class);
register(DisorientNearby.class);
register(DisorientTarget.class);
register(FetchAll.class);
register(FetchDistant.class);
register(FetchNearby.class);
register(FetchTarget.class);
register(FireAura.class);
register(Flood.class);
register(LightningAura.class);
register(LivingBomb.class);
register(ObsidianBomb.class);
register(PullAll.class);
register(PullDistant.class);
register(PullNearby.class);
register(PullTarget.class);
register(RootTarget.class);
register(ShootArrow.class);
register(ShootFireball.class);
register(ShufflePositions.class); | register(ThrowAll.class); |
garbagemule/MobArena | src/main/java/com/garbagemule/MobArena/waves/ability/core/FetchAll.java | // Path: src/main/java/com/garbagemule/MobArena/framework/Arena.java
// public interface Arena
// {
// /*/////////////////////////////////////////////////////////////////////////
// //
// // NEW METHODS IN REFACTORING
// //
// /////////////////////////////////////////////////////////////////////////*/
//
// ConfigurationSection getSettings();
//
// World getWorld();
//
// void setWorld(World world);
//
// boolean isEnabled();
//
// void setEnabled(boolean value);
//
// boolean isProtected();
//
// void setProtected(boolean value);
//
// boolean isRunning();
//
// boolean inEditMode();
//
// void setEditMode(boolean value);
//
// int getMinPlayers();
//
// int getMaxPlayers();
//
// List<Thing> getEntryFee();
//
// Set<Map.Entry<Integer, ThingPicker>> getEveryWaveEntrySet();
//
// ThingPicker getAfterWaveReward(int wave);
//
// Set<Player> getPlayersInArena();
//
// Set<Player> getPlayersInLobby();
//
// Set<Player> getReadyPlayersInLobby();
//
// Set<Player> getSpectators();
//
// MASpawnThread getSpawnThread();
//
// WaveManager getWaveManager();
//
// ArenaListener getEventListener();
//
// void setLeaderboard(Leaderboard leaderboard);
//
// ArenaPlayer getArenaPlayer(Player p);
//
// Set<Block> getBlocks();
//
// void addBlock(Block b);
//
// boolean removeBlock(Block b);
//
// boolean hasPet(Entity e);
//
// void addRepairable(Repairable r);
//
// ArenaRegion getRegion();
//
// InventoryManager getInventoryManager();
//
// RewardManager getRewardManager();
//
// MonsterManager getMonsterManager();
//
// ClassLimitManager getClassLimitManager();
//
// void revivePlayer(Player p);
//
// ScoreboardManager getScoreboard();
//
//
// Messenger getMessenger();
//
// Messenger getGlobalMessenger();
//
// void announce(String msg);
//
// void announce(Msg msg, String s);
//
// void announce(Msg msg);
//
//
//
//
// void scheduleTask(Runnable r, int delay);
//
//
//
//
//
//
//
//
//
//
//
//
// boolean startArena();
//
// boolean endArena();
//
// void forceStart();
//
// void forceEnd();
//
// boolean hasPermission(Player p);
//
// boolean playerJoin(Player p, Location loc);
//
// void playerReady(Player p);
//
// boolean playerLeave(Player p);
//
// boolean isMoving(Player p);
//
// boolean isLeaving(Player p);
//
// void playerDeath(Player p);
//
// void playerRespawn(Player p);
//
// Location getRespawnLocation(Player p);
//
// void playerSpec(Player p, Location loc);
//
// void storeContainerContents();
//
// void restoreContainerContents();
//
// void discardPlayer(Player p);
//
// void repairBlocks();
//
// void queueRepairable(Repairable r);
//
//
//
// /*////////////////////////////////////////////////////////////////////
// //
// // Items & Cleanup
// //
// ////////////////////////////////////////////////////////////////////*/
//
// void assignClass(Player p, String className);
//
// void assignClassGiveInv(Player p, String className, ItemStack[] contents);
//
// void addRandomPlayer(Player p);
//
// void assignRandomClass(Player p);
//
//
//
// /*////////////////////////////////////////////////////////////////////
// //
// // Initialization & Checks
// //
// ////////////////////////////////////////////////////////////////////*/
//
// void restoreRegion();
//
//
//
// /*////////////////////////////////////////////////////////////////////
// //
// // Getters & Misc
// //
// ////////////////////////////////////////////////////////////////////*/
//
// boolean inArena(Player p);
//
// boolean inLobby(Player p);
//
// boolean inSpec(Player p);
//
// boolean isDead(Player p);
//
// String configName();
//
// /**
// * @deprecated use {@link #configName()} instead
// */
// @Deprecated
// String arenaName();
//
// String getSlug();
//
// MobArena getPlugin();
//
// Map<String,ArenaClass> getClasses();
//
// int getPlayerCount();
//
// List<Player> getAllPlayers();
//
// Collection<ArenaPlayer> getArenaPlayerSet();
//
// List<Player> getNonreadyPlayers();
//
// boolean canAfford(Player p);
//
// boolean takeFee(Player p);
//
// boolean refund(Player p);
//
// boolean canJoin(Player p);
//
// boolean canSpec(Player p);
//
// boolean hasIsolatedChat();
//
// Player getLastPlayerStanding();
//
// AutoStartTimer getAutoStartTimer();
// }
| import com.garbagemule.MobArena.framework.Arena;
import com.garbagemule.MobArena.waves.MABoss;
import com.garbagemule.MobArena.waves.ability.Ability;
import com.garbagemule.MobArena.waves.ability.AbilityInfo;
import org.bukkit.Location;
import org.bukkit.entity.Player; | package com.garbagemule.MobArena.waves.ability.core;
@AbilityInfo(
name = "Fetch All",
aliases = {"fetchall"}
)
public class FetchAll implements Ability
{
@Override | // Path: src/main/java/com/garbagemule/MobArena/framework/Arena.java
// public interface Arena
// {
// /*/////////////////////////////////////////////////////////////////////////
// //
// // NEW METHODS IN REFACTORING
// //
// /////////////////////////////////////////////////////////////////////////*/
//
// ConfigurationSection getSettings();
//
// World getWorld();
//
// void setWorld(World world);
//
// boolean isEnabled();
//
// void setEnabled(boolean value);
//
// boolean isProtected();
//
// void setProtected(boolean value);
//
// boolean isRunning();
//
// boolean inEditMode();
//
// void setEditMode(boolean value);
//
// int getMinPlayers();
//
// int getMaxPlayers();
//
// List<Thing> getEntryFee();
//
// Set<Map.Entry<Integer, ThingPicker>> getEveryWaveEntrySet();
//
// ThingPicker getAfterWaveReward(int wave);
//
// Set<Player> getPlayersInArena();
//
// Set<Player> getPlayersInLobby();
//
// Set<Player> getReadyPlayersInLobby();
//
// Set<Player> getSpectators();
//
// MASpawnThread getSpawnThread();
//
// WaveManager getWaveManager();
//
// ArenaListener getEventListener();
//
// void setLeaderboard(Leaderboard leaderboard);
//
// ArenaPlayer getArenaPlayer(Player p);
//
// Set<Block> getBlocks();
//
// void addBlock(Block b);
//
// boolean removeBlock(Block b);
//
// boolean hasPet(Entity e);
//
// void addRepairable(Repairable r);
//
// ArenaRegion getRegion();
//
// InventoryManager getInventoryManager();
//
// RewardManager getRewardManager();
//
// MonsterManager getMonsterManager();
//
// ClassLimitManager getClassLimitManager();
//
// void revivePlayer(Player p);
//
// ScoreboardManager getScoreboard();
//
//
// Messenger getMessenger();
//
// Messenger getGlobalMessenger();
//
// void announce(String msg);
//
// void announce(Msg msg, String s);
//
// void announce(Msg msg);
//
//
//
//
// void scheduleTask(Runnable r, int delay);
//
//
//
//
//
//
//
//
//
//
//
//
// boolean startArena();
//
// boolean endArena();
//
// void forceStart();
//
// void forceEnd();
//
// boolean hasPermission(Player p);
//
// boolean playerJoin(Player p, Location loc);
//
// void playerReady(Player p);
//
// boolean playerLeave(Player p);
//
// boolean isMoving(Player p);
//
// boolean isLeaving(Player p);
//
// void playerDeath(Player p);
//
// void playerRespawn(Player p);
//
// Location getRespawnLocation(Player p);
//
// void playerSpec(Player p, Location loc);
//
// void storeContainerContents();
//
// void restoreContainerContents();
//
// void discardPlayer(Player p);
//
// void repairBlocks();
//
// void queueRepairable(Repairable r);
//
//
//
// /*////////////////////////////////////////////////////////////////////
// //
// // Items & Cleanup
// //
// ////////////////////////////////////////////////////////////////////*/
//
// void assignClass(Player p, String className);
//
// void assignClassGiveInv(Player p, String className, ItemStack[] contents);
//
// void addRandomPlayer(Player p);
//
// void assignRandomClass(Player p);
//
//
//
// /*////////////////////////////////////////////////////////////////////
// //
// // Initialization & Checks
// //
// ////////////////////////////////////////////////////////////////////*/
//
// void restoreRegion();
//
//
//
// /*////////////////////////////////////////////////////////////////////
// //
// // Getters & Misc
// //
// ////////////////////////////////////////////////////////////////////*/
//
// boolean inArena(Player p);
//
// boolean inLobby(Player p);
//
// boolean inSpec(Player p);
//
// boolean isDead(Player p);
//
// String configName();
//
// /**
// * @deprecated use {@link #configName()} instead
// */
// @Deprecated
// String arenaName();
//
// String getSlug();
//
// MobArena getPlugin();
//
// Map<String,ArenaClass> getClasses();
//
// int getPlayerCount();
//
// List<Player> getAllPlayers();
//
// Collection<ArenaPlayer> getArenaPlayerSet();
//
// List<Player> getNonreadyPlayers();
//
// boolean canAfford(Player p);
//
// boolean takeFee(Player p);
//
// boolean refund(Player p);
//
// boolean canJoin(Player p);
//
// boolean canSpec(Player p);
//
// boolean hasIsolatedChat();
//
// Player getLastPlayerStanding();
//
// AutoStartTimer getAutoStartTimer();
// }
// Path: src/main/java/com/garbagemule/MobArena/waves/ability/core/FetchAll.java
import com.garbagemule.MobArena.framework.Arena;
import com.garbagemule.MobArena.waves.MABoss;
import com.garbagemule.MobArena.waves.ability.Ability;
import com.garbagemule.MobArena.waves.ability.AbilityInfo;
import org.bukkit.Location;
import org.bukkit.entity.Player;
package com.garbagemule.MobArena.waves.ability.core;
@AbilityInfo(
name = "Fetch All",
aliases = {"fetchall"}
)
public class FetchAll implements Ability
{
@Override | public void execute(Arena arena, MABoss boss) { |
garbagemule/MobArena | src/main/java/com/garbagemule/MobArena/waves/ability/core/PullAll.java | // Path: src/main/java/com/garbagemule/MobArena/framework/Arena.java
// public interface Arena
// {
// /*/////////////////////////////////////////////////////////////////////////
// //
// // NEW METHODS IN REFACTORING
// //
// /////////////////////////////////////////////////////////////////////////*/
//
// ConfigurationSection getSettings();
//
// World getWorld();
//
// void setWorld(World world);
//
// boolean isEnabled();
//
// void setEnabled(boolean value);
//
// boolean isProtected();
//
// void setProtected(boolean value);
//
// boolean isRunning();
//
// boolean inEditMode();
//
// void setEditMode(boolean value);
//
// int getMinPlayers();
//
// int getMaxPlayers();
//
// List<Thing> getEntryFee();
//
// Set<Map.Entry<Integer, ThingPicker>> getEveryWaveEntrySet();
//
// ThingPicker getAfterWaveReward(int wave);
//
// Set<Player> getPlayersInArena();
//
// Set<Player> getPlayersInLobby();
//
// Set<Player> getReadyPlayersInLobby();
//
// Set<Player> getSpectators();
//
// MASpawnThread getSpawnThread();
//
// WaveManager getWaveManager();
//
// ArenaListener getEventListener();
//
// void setLeaderboard(Leaderboard leaderboard);
//
// ArenaPlayer getArenaPlayer(Player p);
//
// Set<Block> getBlocks();
//
// void addBlock(Block b);
//
// boolean removeBlock(Block b);
//
// boolean hasPet(Entity e);
//
// void addRepairable(Repairable r);
//
// ArenaRegion getRegion();
//
// InventoryManager getInventoryManager();
//
// RewardManager getRewardManager();
//
// MonsterManager getMonsterManager();
//
// ClassLimitManager getClassLimitManager();
//
// void revivePlayer(Player p);
//
// ScoreboardManager getScoreboard();
//
//
// Messenger getMessenger();
//
// Messenger getGlobalMessenger();
//
// void announce(String msg);
//
// void announce(Msg msg, String s);
//
// void announce(Msg msg);
//
//
//
//
// void scheduleTask(Runnable r, int delay);
//
//
//
//
//
//
//
//
//
//
//
//
// boolean startArena();
//
// boolean endArena();
//
// void forceStart();
//
// void forceEnd();
//
// boolean hasPermission(Player p);
//
// boolean playerJoin(Player p, Location loc);
//
// void playerReady(Player p);
//
// boolean playerLeave(Player p);
//
// boolean isMoving(Player p);
//
// boolean isLeaving(Player p);
//
// void playerDeath(Player p);
//
// void playerRespawn(Player p);
//
// Location getRespawnLocation(Player p);
//
// void playerSpec(Player p, Location loc);
//
// void storeContainerContents();
//
// void restoreContainerContents();
//
// void discardPlayer(Player p);
//
// void repairBlocks();
//
// void queueRepairable(Repairable r);
//
//
//
// /*////////////////////////////////////////////////////////////////////
// //
// // Items & Cleanup
// //
// ////////////////////////////////////////////////////////////////////*/
//
// void assignClass(Player p, String className);
//
// void assignClassGiveInv(Player p, String className, ItemStack[] contents);
//
// void addRandomPlayer(Player p);
//
// void assignRandomClass(Player p);
//
//
//
// /*////////////////////////////////////////////////////////////////////
// //
// // Initialization & Checks
// //
// ////////////////////////////////////////////////////////////////////*/
//
// void restoreRegion();
//
//
//
// /*////////////////////////////////////////////////////////////////////
// //
// // Getters & Misc
// //
// ////////////////////////////////////////////////////////////////////*/
//
// boolean inArena(Player p);
//
// boolean inLobby(Player p);
//
// boolean inSpec(Player p);
//
// boolean isDead(Player p);
//
// String configName();
//
// /**
// * @deprecated use {@link #configName()} instead
// */
// @Deprecated
// String arenaName();
//
// String getSlug();
//
// MobArena getPlugin();
//
// Map<String,ArenaClass> getClasses();
//
// int getPlayerCount();
//
// List<Player> getAllPlayers();
//
// Collection<ArenaPlayer> getArenaPlayerSet();
//
// List<Player> getNonreadyPlayers();
//
// boolean canAfford(Player p);
//
// boolean takeFee(Player p);
//
// boolean refund(Player p);
//
// boolean canJoin(Player p);
//
// boolean canSpec(Player p);
//
// boolean hasIsolatedChat();
//
// Player getLastPlayerStanding();
//
// AutoStartTimer getAutoStartTimer();
// }
| import com.garbagemule.MobArena.framework.Arena;
import com.garbagemule.MobArena.waves.MABoss;
import com.garbagemule.MobArena.waves.ability.Ability;
import com.garbagemule.MobArena.waves.ability.AbilityInfo;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector; | package com.garbagemule.MobArena.waves.ability.core;
@AbilityInfo(
name = "Pull All",
aliases = {"pullall"}
)
public class PullAll implements Ability
{
@Override | // Path: src/main/java/com/garbagemule/MobArena/framework/Arena.java
// public interface Arena
// {
// /*/////////////////////////////////////////////////////////////////////////
// //
// // NEW METHODS IN REFACTORING
// //
// /////////////////////////////////////////////////////////////////////////*/
//
// ConfigurationSection getSettings();
//
// World getWorld();
//
// void setWorld(World world);
//
// boolean isEnabled();
//
// void setEnabled(boolean value);
//
// boolean isProtected();
//
// void setProtected(boolean value);
//
// boolean isRunning();
//
// boolean inEditMode();
//
// void setEditMode(boolean value);
//
// int getMinPlayers();
//
// int getMaxPlayers();
//
// List<Thing> getEntryFee();
//
// Set<Map.Entry<Integer, ThingPicker>> getEveryWaveEntrySet();
//
// ThingPicker getAfterWaveReward(int wave);
//
// Set<Player> getPlayersInArena();
//
// Set<Player> getPlayersInLobby();
//
// Set<Player> getReadyPlayersInLobby();
//
// Set<Player> getSpectators();
//
// MASpawnThread getSpawnThread();
//
// WaveManager getWaveManager();
//
// ArenaListener getEventListener();
//
// void setLeaderboard(Leaderboard leaderboard);
//
// ArenaPlayer getArenaPlayer(Player p);
//
// Set<Block> getBlocks();
//
// void addBlock(Block b);
//
// boolean removeBlock(Block b);
//
// boolean hasPet(Entity e);
//
// void addRepairable(Repairable r);
//
// ArenaRegion getRegion();
//
// InventoryManager getInventoryManager();
//
// RewardManager getRewardManager();
//
// MonsterManager getMonsterManager();
//
// ClassLimitManager getClassLimitManager();
//
// void revivePlayer(Player p);
//
// ScoreboardManager getScoreboard();
//
//
// Messenger getMessenger();
//
// Messenger getGlobalMessenger();
//
// void announce(String msg);
//
// void announce(Msg msg, String s);
//
// void announce(Msg msg);
//
//
//
//
// void scheduleTask(Runnable r, int delay);
//
//
//
//
//
//
//
//
//
//
//
//
// boolean startArena();
//
// boolean endArena();
//
// void forceStart();
//
// void forceEnd();
//
// boolean hasPermission(Player p);
//
// boolean playerJoin(Player p, Location loc);
//
// void playerReady(Player p);
//
// boolean playerLeave(Player p);
//
// boolean isMoving(Player p);
//
// boolean isLeaving(Player p);
//
// void playerDeath(Player p);
//
// void playerRespawn(Player p);
//
// Location getRespawnLocation(Player p);
//
// void playerSpec(Player p, Location loc);
//
// void storeContainerContents();
//
// void restoreContainerContents();
//
// void discardPlayer(Player p);
//
// void repairBlocks();
//
// void queueRepairable(Repairable r);
//
//
//
// /*////////////////////////////////////////////////////////////////////
// //
// // Items & Cleanup
// //
// ////////////////////////////////////////////////////////////////////*/
//
// void assignClass(Player p, String className);
//
// void assignClassGiveInv(Player p, String className, ItemStack[] contents);
//
// void addRandomPlayer(Player p);
//
// void assignRandomClass(Player p);
//
//
//
// /*////////////////////////////////////////////////////////////////////
// //
// // Initialization & Checks
// //
// ////////////////////////////////////////////////////////////////////*/
//
// void restoreRegion();
//
//
//
// /*////////////////////////////////////////////////////////////////////
// //
// // Getters & Misc
// //
// ////////////////////////////////////////////////////////////////////*/
//
// boolean inArena(Player p);
//
// boolean inLobby(Player p);
//
// boolean inSpec(Player p);
//
// boolean isDead(Player p);
//
// String configName();
//
// /**
// * @deprecated use {@link #configName()} instead
// */
// @Deprecated
// String arenaName();
//
// String getSlug();
//
// MobArena getPlugin();
//
// Map<String,ArenaClass> getClasses();
//
// int getPlayerCount();
//
// List<Player> getAllPlayers();
//
// Collection<ArenaPlayer> getArenaPlayerSet();
//
// List<Player> getNonreadyPlayers();
//
// boolean canAfford(Player p);
//
// boolean takeFee(Player p);
//
// boolean refund(Player p);
//
// boolean canJoin(Player p);
//
// boolean canSpec(Player p);
//
// boolean hasIsolatedChat();
//
// Player getLastPlayerStanding();
//
// AutoStartTimer getAutoStartTimer();
// }
// Path: src/main/java/com/garbagemule/MobArena/waves/ability/core/PullAll.java
import com.garbagemule.MobArena.framework.Arena;
import com.garbagemule.MobArena.waves.MABoss;
import com.garbagemule.MobArena.waves.ability.Ability;
import com.garbagemule.MobArena.waves.ability.AbilityInfo;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
package com.garbagemule.MobArena.waves.ability.core;
@AbilityInfo(
name = "Pull All",
aliases = {"pullall"}
)
public class PullAll implements Ability
{
@Override | public void execute(Arena arena, MABoss boss) { |
garbagemule/MobArena | src/main/java/com/garbagemule/MobArena/waves/ability/core/ThrowAll.java | // Path: src/main/java/com/garbagemule/MobArena/framework/Arena.java
// public interface Arena
// {
// /*/////////////////////////////////////////////////////////////////////////
// //
// // NEW METHODS IN REFACTORING
// //
// /////////////////////////////////////////////////////////////////////////*/
//
// ConfigurationSection getSettings();
//
// World getWorld();
//
// void setWorld(World world);
//
// boolean isEnabled();
//
// void setEnabled(boolean value);
//
// boolean isProtected();
//
// void setProtected(boolean value);
//
// boolean isRunning();
//
// boolean inEditMode();
//
// void setEditMode(boolean value);
//
// int getMinPlayers();
//
// int getMaxPlayers();
//
// List<Thing> getEntryFee();
//
// Set<Map.Entry<Integer, ThingPicker>> getEveryWaveEntrySet();
//
// ThingPicker getAfterWaveReward(int wave);
//
// Set<Player> getPlayersInArena();
//
// Set<Player> getPlayersInLobby();
//
// Set<Player> getReadyPlayersInLobby();
//
// Set<Player> getSpectators();
//
// MASpawnThread getSpawnThread();
//
// WaveManager getWaveManager();
//
// ArenaListener getEventListener();
//
// void setLeaderboard(Leaderboard leaderboard);
//
// ArenaPlayer getArenaPlayer(Player p);
//
// Set<Block> getBlocks();
//
// void addBlock(Block b);
//
// boolean removeBlock(Block b);
//
// boolean hasPet(Entity e);
//
// void addRepairable(Repairable r);
//
// ArenaRegion getRegion();
//
// InventoryManager getInventoryManager();
//
// RewardManager getRewardManager();
//
// MonsterManager getMonsterManager();
//
// ClassLimitManager getClassLimitManager();
//
// void revivePlayer(Player p);
//
// ScoreboardManager getScoreboard();
//
//
// Messenger getMessenger();
//
// Messenger getGlobalMessenger();
//
// void announce(String msg);
//
// void announce(Msg msg, String s);
//
// void announce(Msg msg);
//
//
//
//
// void scheduleTask(Runnable r, int delay);
//
//
//
//
//
//
//
//
//
//
//
//
// boolean startArena();
//
// boolean endArena();
//
// void forceStart();
//
// void forceEnd();
//
// boolean hasPermission(Player p);
//
// boolean playerJoin(Player p, Location loc);
//
// void playerReady(Player p);
//
// boolean playerLeave(Player p);
//
// boolean isMoving(Player p);
//
// boolean isLeaving(Player p);
//
// void playerDeath(Player p);
//
// void playerRespawn(Player p);
//
// Location getRespawnLocation(Player p);
//
// void playerSpec(Player p, Location loc);
//
// void storeContainerContents();
//
// void restoreContainerContents();
//
// void discardPlayer(Player p);
//
// void repairBlocks();
//
// void queueRepairable(Repairable r);
//
//
//
// /*////////////////////////////////////////////////////////////////////
// //
// // Items & Cleanup
// //
// ////////////////////////////////////////////////////////////////////*/
//
// void assignClass(Player p, String className);
//
// void assignClassGiveInv(Player p, String className, ItemStack[] contents);
//
// void addRandomPlayer(Player p);
//
// void assignRandomClass(Player p);
//
//
//
// /*////////////////////////////////////////////////////////////////////
// //
// // Initialization & Checks
// //
// ////////////////////////////////////////////////////////////////////*/
//
// void restoreRegion();
//
//
//
// /*////////////////////////////////////////////////////////////////////
// //
// // Getters & Misc
// //
// ////////////////////////////////////////////////////////////////////*/
//
// boolean inArena(Player p);
//
// boolean inLobby(Player p);
//
// boolean inSpec(Player p);
//
// boolean isDead(Player p);
//
// String configName();
//
// /**
// * @deprecated use {@link #configName()} instead
// */
// @Deprecated
// String arenaName();
//
// String getSlug();
//
// MobArena getPlugin();
//
// Map<String,ArenaClass> getClasses();
//
// int getPlayerCount();
//
// List<Player> getAllPlayers();
//
// Collection<ArenaPlayer> getArenaPlayerSet();
//
// List<Player> getNonreadyPlayers();
//
// boolean canAfford(Player p);
//
// boolean takeFee(Player p);
//
// boolean refund(Player p);
//
// boolean canJoin(Player p);
//
// boolean canSpec(Player p);
//
// boolean hasIsolatedChat();
//
// Player getLastPlayerStanding();
//
// AutoStartTimer getAutoStartTimer();
// }
| import com.garbagemule.MobArena.framework.Arena;
import com.garbagemule.MobArena.waves.MABoss;
import com.garbagemule.MobArena.waves.ability.Ability;
import com.garbagemule.MobArena.waves.ability.AbilityInfo;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector; | package com.garbagemule.MobArena.waves.ability.core;
@AbilityInfo(
name = "Throw All",
aliases = {"throwall"}
)
public class ThrowAll implements Ability
{
@Override | // Path: src/main/java/com/garbagemule/MobArena/framework/Arena.java
// public interface Arena
// {
// /*/////////////////////////////////////////////////////////////////////////
// //
// // NEW METHODS IN REFACTORING
// //
// /////////////////////////////////////////////////////////////////////////*/
//
// ConfigurationSection getSettings();
//
// World getWorld();
//
// void setWorld(World world);
//
// boolean isEnabled();
//
// void setEnabled(boolean value);
//
// boolean isProtected();
//
// void setProtected(boolean value);
//
// boolean isRunning();
//
// boolean inEditMode();
//
// void setEditMode(boolean value);
//
// int getMinPlayers();
//
// int getMaxPlayers();
//
// List<Thing> getEntryFee();
//
// Set<Map.Entry<Integer, ThingPicker>> getEveryWaveEntrySet();
//
// ThingPicker getAfterWaveReward(int wave);
//
// Set<Player> getPlayersInArena();
//
// Set<Player> getPlayersInLobby();
//
// Set<Player> getReadyPlayersInLobby();
//
// Set<Player> getSpectators();
//
// MASpawnThread getSpawnThread();
//
// WaveManager getWaveManager();
//
// ArenaListener getEventListener();
//
// void setLeaderboard(Leaderboard leaderboard);
//
// ArenaPlayer getArenaPlayer(Player p);
//
// Set<Block> getBlocks();
//
// void addBlock(Block b);
//
// boolean removeBlock(Block b);
//
// boolean hasPet(Entity e);
//
// void addRepairable(Repairable r);
//
// ArenaRegion getRegion();
//
// InventoryManager getInventoryManager();
//
// RewardManager getRewardManager();
//
// MonsterManager getMonsterManager();
//
// ClassLimitManager getClassLimitManager();
//
// void revivePlayer(Player p);
//
// ScoreboardManager getScoreboard();
//
//
// Messenger getMessenger();
//
// Messenger getGlobalMessenger();
//
// void announce(String msg);
//
// void announce(Msg msg, String s);
//
// void announce(Msg msg);
//
//
//
//
// void scheduleTask(Runnable r, int delay);
//
//
//
//
//
//
//
//
//
//
//
//
// boolean startArena();
//
// boolean endArena();
//
// void forceStart();
//
// void forceEnd();
//
// boolean hasPermission(Player p);
//
// boolean playerJoin(Player p, Location loc);
//
// void playerReady(Player p);
//
// boolean playerLeave(Player p);
//
// boolean isMoving(Player p);
//
// boolean isLeaving(Player p);
//
// void playerDeath(Player p);
//
// void playerRespawn(Player p);
//
// Location getRespawnLocation(Player p);
//
// void playerSpec(Player p, Location loc);
//
// void storeContainerContents();
//
// void restoreContainerContents();
//
// void discardPlayer(Player p);
//
// void repairBlocks();
//
// void queueRepairable(Repairable r);
//
//
//
// /*////////////////////////////////////////////////////////////////////
// //
// // Items & Cleanup
// //
// ////////////////////////////////////////////////////////////////////*/
//
// void assignClass(Player p, String className);
//
// void assignClassGiveInv(Player p, String className, ItemStack[] contents);
//
// void addRandomPlayer(Player p);
//
// void assignRandomClass(Player p);
//
//
//
// /*////////////////////////////////////////////////////////////////////
// //
// // Initialization & Checks
// //
// ////////////////////////////////////////////////////////////////////*/
//
// void restoreRegion();
//
//
//
// /*////////////////////////////////////////////////////////////////////
// //
// // Getters & Misc
// //
// ////////////////////////////////////////////////////////////////////*/
//
// boolean inArena(Player p);
//
// boolean inLobby(Player p);
//
// boolean inSpec(Player p);
//
// boolean isDead(Player p);
//
// String configName();
//
// /**
// * @deprecated use {@link #configName()} instead
// */
// @Deprecated
// String arenaName();
//
// String getSlug();
//
// MobArena getPlugin();
//
// Map<String,ArenaClass> getClasses();
//
// int getPlayerCount();
//
// List<Player> getAllPlayers();
//
// Collection<ArenaPlayer> getArenaPlayerSet();
//
// List<Player> getNonreadyPlayers();
//
// boolean canAfford(Player p);
//
// boolean takeFee(Player p);
//
// boolean refund(Player p);
//
// boolean canJoin(Player p);
//
// boolean canSpec(Player p);
//
// boolean hasIsolatedChat();
//
// Player getLastPlayerStanding();
//
// AutoStartTimer getAutoStartTimer();
// }
// Path: src/main/java/com/garbagemule/MobArena/waves/ability/core/ThrowAll.java
import com.garbagemule.MobArena.framework.Arena;
import com.garbagemule.MobArena.waves.MABoss;
import com.garbagemule.MobArena.waves.ability.Ability;
import com.garbagemule.MobArena.waves.ability.AbilityInfo;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
package com.garbagemule.MobArena.waves.ability.core;
@AbilityInfo(
name = "Throw All",
aliases = {"throwall"}
)
public class ThrowAll implements Ability
{
@Override | public void execute(Arena arena, MABoss boss) { |
sequarius/SequariusToys | LightPlayer/src/com/sequarius/lightplayer/SearchMusicActivity.java | // Path: LightPlayer/src/com/sequarius/lightplayer/database/PlayListDAO.java
// public class PlayListDAO {
// private PlayListSQLiteOpenHelper helper;
// public PlayListDAO(Context context){
// helper =new PlayListSQLiteOpenHelper(context);
// }
// /**
// * Ìí¼ÓÒ»Ìõ¼Ç¼
// * @param name ÎļþÃû
// * @param uri ÎļþµØÖ·
// */
// public void add(String name,String uri){
// SQLiteDatabase db=helper.getWritableDatabase();
// db.execSQL("insert into playlist (name,uri) values(?,?)",new Object[]{name,uri});
// db.close();
// }
// /**
// * ²éѯËùÓиèÇúÁбí
// * @return ËùÓÐÔÚ¿â¸èÇú
// */
// public List<Song> selectAll(){
// SQLiteDatabase db=helper.getReadableDatabase();
// Cursor cursor=db.rawQuery("select * from playlist", null);
// List<Song> songs=new ArrayList<Song>();
// while(cursor.moveToNext()){
// int id=cursor.getInt(cursor.getColumnIndex("id"));
// String name=cursor.getString(cursor.getColumnIndex("name"));
// String uri=cursor.getString(cursor.getColumnIndex("uri"));
// Song song=new Song(id, name,uri );
// songs.add(song);
// }
// cursor.close();
// db.close();
// return songs;
// }
// public void clear(){
// SQLiteDatabase db=helper.getWritableDatabase();
// db.execSQL("delete from playlist");//Çå¿Õ±í
// db.execSQL("update sqlite_sequence set seq=0 where name='playlist'");//ÖØÖÃid×ÔÔö¶Î
// db.close();
// }
// }
//
// Path: LightPlayer/src/com/sequarius/lightplayer/tools/FileFilterBySuffix.java
// public class FileFilterBySuffix implements FileFilter {
//
// private String suffix;
//
// public FileFilterBySuffix(String suffix) {
// super();
// this.suffix = suffix;
// }
//
// @Override
// public boolean accept(File pathname) {
//
// return pathname.getName().endsWith(suffix);
// }
// }
//
// Path: LightPlayer/src/com/sequarius/lightplayer/tools/Queue.java
// public class Queue<E> {
// private LinkedList<E> link;
//
// /**
// * ÌṩÁ˹¹Ôì¶ÓÁжÔÏóµÄ¹¹ÔìÆ÷¡£
// */
// public Queue() {
// link = new LinkedList<E>();
// }
//
// /**
// * Ìí¼ÓÔªËØµÄ·½·¨¡£
// */
// public void myAdd(E obj) {
// link.addFirst(obj);
// }
//
// /**
// * »ñÈ¡µÄ·½·¨¡£
// */
// public E myGet() {
// return link.removeLast();
// }
//
// /**
// * Åж϶ÓÁÐÊÇ·ñÓÐÔªËØ¡£
// */
// public boolean isNull() {
// return link.isEmpty();
// }
// }
| import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList;
import java.util.List;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
import com.sequarius.lightplayer.database.PlayListDAO;
import com.sequarius.lightplayer.tools.FileFilterBySuffix;
import com.sequarius.lightplayer.tools.Queue;
| package com.sequarius.lightplayer;
public class SearchMusicActivity extends Activity {
PlayListDAO mPlayListDAO;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
mPlayListDAO = new PlayListDAO(this);
setContentView(R.layout.layout_search_music);
Button button = (Button) findViewById(R.id.button_search_music);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
int count = searchMusicFile();
Toast.makeText(SearchMusicActivity.this,
"ɨÃèÍê±Ï,¹²ÕÒµ½" + count + "¸öÒôÀÖÎļþ¡£", Toast.LENGTH_SHORT)
.show();
finish();
}
});
}
/**
* ±éÀúSD¿¨ËùÓÐMP3Îļþ
*
* @return ÕÒµ½µÄMP3ÊýÁ¿
*/
public int searchMusicFile() {
// ɨÃèĿ¼
File dir = new File("sdcard/");
// ¹ýÂËÆ÷
| // Path: LightPlayer/src/com/sequarius/lightplayer/database/PlayListDAO.java
// public class PlayListDAO {
// private PlayListSQLiteOpenHelper helper;
// public PlayListDAO(Context context){
// helper =new PlayListSQLiteOpenHelper(context);
// }
// /**
// * Ìí¼ÓÒ»Ìõ¼Ç¼
// * @param name ÎļþÃû
// * @param uri ÎļþµØÖ·
// */
// public void add(String name,String uri){
// SQLiteDatabase db=helper.getWritableDatabase();
// db.execSQL("insert into playlist (name,uri) values(?,?)",new Object[]{name,uri});
// db.close();
// }
// /**
// * ²éѯËùÓиèÇúÁбí
// * @return ËùÓÐÔÚ¿â¸èÇú
// */
// public List<Song> selectAll(){
// SQLiteDatabase db=helper.getReadableDatabase();
// Cursor cursor=db.rawQuery("select * from playlist", null);
// List<Song> songs=new ArrayList<Song>();
// while(cursor.moveToNext()){
// int id=cursor.getInt(cursor.getColumnIndex("id"));
// String name=cursor.getString(cursor.getColumnIndex("name"));
// String uri=cursor.getString(cursor.getColumnIndex("uri"));
// Song song=new Song(id, name,uri );
// songs.add(song);
// }
// cursor.close();
// db.close();
// return songs;
// }
// public void clear(){
// SQLiteDatabase db=helper.getWritableDatabase();
// db.execSQL("delete from playlist");//Çå¿Õ±í
// db.execSQL("update sqlite_sequence set seq=0 where name='playlist'");//ÖØÖÃid×ÔÔö¶Î
// db.close();
// }
// }
//
// Path: LightPlayer/src/com/sequarius/lightplayer/tools/FileFilterBySuffix.java
// public class FileFilterBySuffix implements FileFilter {
//
// private String suffix;
//
// public FileFilterBySuffix(String suffix) {
// super();
// this.suffix = suffix;
// }
//
// @Override
// public boolean accept(File pathname) {
//
// return pathname.getName().endsWith(suffix);
// }
// }
//
// Path: LightPlayer/src/com/sequarius/lightplayer/tools/Queue.java
// public class Queue<E> {
// private LinkedList<E> link;
//
// /**
// * ÌṩÁ˹¹Ôì¶ÓÁжÔÏóµÄ¹¹ÔìÆ÷¡£
// */
// public Queue() {
// link = new LinkedList<E>();
// }
//
// /**
// * Ìí¼ÓÔªËØµÄ·½·¨¡£
// */
// public void myAdd(E obj) {
// link.addFirst(obj);
// }
//
// /**
// * »ñÈ¡µÄ·½·¨¡£
// */
// public E myGet() {
// return link.removeLast();
// }
//
// /**
// * Åж϶ÓÁÐÊÇ·ñÓÐÔªËØ¡£
// */
// public boolean isNull() {
// return link.isEmpty();
// }
// }
// Path: LightPlayer/src/com/sequarius/lightplayer/SearchMusicActivity.java
import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList;
import java.util.List;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
import com.sequarius.lightplayer.database.PlayListDAO;
import com.sequarius.lightplayer.tools.FileFilterBySuffix;
import com.sequarius.lightplayer.tools.Queue;
package com.sequarius.lightplayer;
public class SearchMusicActivity extends Activity {
PlayListDAO mPlayListDAO;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
mPlayListDAO = new PlayListDAO(this);
setContentView(R.layout.layout_search_music);
Button button = (Button) findViewById(R.id.button_search_music);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
int count = searchMusicFile();
Toast.makeText(SearchMusicActivity.this,
"ɨÃèÍê±Ï,¹²ÕÒµ½" + count + "¸öÒôÀÖÎļþ¡£", Toast.LENGTH_SHORT)
.show();
finish();
}
});
}
/**
* ±éÀúSD¿¨ËùÓÐMP3Îļþ
*
* @return ÕÒµ½µÄMP3ÊýÁ¿
*/
public int searchMusicFile() {
// ɨÃèĿ¼
File dir = new File("sdcard/");
// ¹ýÂËÆ÷
| FileFilter filter = new FileFilterBySuffix("mp3");
|
sequarius/SequariusToys | LightPlayer/src/com/sequarius/lightplayer/SearchMusicActivity.java | // Path: LightPlayer/src/com/sequarius/lightplayer/database/PlayListDAO.java
// public class PlayListDAO {
// private PlayListSQLiteOpenHelper helper;
// public PlayListDAO(Context context){
// helper =new PlayListSQLiteOpenHelper(context);
// }
// /**
// * Ìí¼ÓÒ»Ìõ¼Ç¼
// * @param name ÎļþÃû
// * @param uri ÎļþµØÖ·
// */
// public void add(String name,String uri){
// SQLiteDatabase db=helper.getWritableDatabase();
// db.execSQL("insert into playlist (name,uri) values(?,?)",new Object[]{name,uri});
// db.close();
// }
// /**
// * ²éѯËùÓиèÇúÁбí
// * @return ËùÓÐÔÚ¿â¸èÇú
// */
// public List<Song> selectAll(){
// SQLiteDatabase db=helper.getReadableDatabase();
// Cursor cursor=db.rawQuery("select * from playlist", null);
// List<Song> songs=new ArrayList<Song>();
// while(cursor.moveToNext()){
// int id=cursor.getInt(cursor.getColumnIndex("id"));
// String name=cursor.getString(cursor.getColumnIndex("name"));
// String uri=cursor.getString(cursor.getColumnIndex("uri"));
// Song song=new Song(id, name,uri );
// songs.add(song);
// }
// cursor.close();
// db.close();
// return songs;
// }
// public void clear(){
// SQLiteDatabase db=helper.getWritableDatabase();
// db.execSQL("delete from playlist");//Çå¿Õ±í
// db.execSQL("update sqlite_sequence set seq=0 where name='playlist'");//ÖØÖÃid×ÔÔö¶Î
// db.close();
// }
// }
//
// Path: LightPlayer/src/com/sequarius/lightplayer/tools/FileFilterBySuffix.java
// public class FileFilterBySuffix implements FileFilter {
//
// private String suffix;
//
// public FileFilterBySuffix(String suffix) {
// super();
// this.suffix = suffix;
// }
//
// @Override
// public boolean accept(File pathname) {
//
// return pathname.getName().endsWith(suffix);
// }
// }
//
// Path: LightPlayer/src/com/sequarius/lightplayer/tools/Queue.java
// public class Queue<E> {
// private LinkedList<E> link;
//
// /**
// * ÌṩÁ˹¹Ôì¶ÓÁжÔÏóµÄ¹¹ÔìÆ÷¡£
// */
// public Queue() {
// link = new LinkedList<E>();
// }
//
// /**
// * Ìí¼ÓÔªËØµÄ·½·¨¡£
// */
// public void myAdd(E obj) {
// link.addFirst(obj);
// }
//
// /**
// * »ñÈ¡µÄ·½·¨¡£
// */
// public E myGet() {
// return link.removeLast();
// }
//
// /**
// * Åж϶ÓÁÐÊÇ·ñÓÐÔªËØ¡£
// */
// public boolean isNull() {
// return link.isEmpty();
// }
// }
| import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList;
import java.util.List;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
import com.sequarius.lightplayer.database.PlayListDAO;
import com.sequarius.lightplayer.tools.FileFilterBySuffix;
import com.sequarius.lightplayer.tools.Queue;
| package com.sequarius.lightplayer;
public class SearchMusicActivity extends Activity {
PlayListDAO mPlayListDAO;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
mPlayListDAO = new PlayListDAO(this);
setContentView(R.layout.layout_search_music);
Button button = (Button) findViewById(R.id.button_search_music);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
int count = searchMusicFile();
Toast.makeText(SearchMusicActivity.this,
"ɨÃèÍê±Ï,¹²ÕÒµ½" + count + "¸öÒôÀÖÎļþ¡£", Toast.LENGTH_SHORT)
.show();
finish();
}
});
}
/**
* ±éÀúSD¿¨ËùÓÐMP3Îļþ
*
* @return ÕÒµ½µÄMP3ÊýÁ¿
*/
public int searchMusicFile() {
// ɨÃèĿ¼
File dir = new File("sdcard/");
// ¹ýÂËÆ÷
FileFilter filter = new FileFilterBySuffix("mp3");
// ´¢´æ·ûºÏÒªÇóµÄÎļþ
List<File> list = new ArrayList<File>();
// getFileList(dir, filter, list);
| // Path: LightPlayer/src/com/sequarius/lightplayer/database/PlayListDAO.java
// public class PlayListDAO {
// private PlayListSQLiteOpenHelper helper;
// public PlayListDAO(Context context){
// helper =new PlayListSQLiteOpenHelper(context);
// }
// /**
// * Ìí¼ÓÒ»Ìõ¼Ç¼
// * @param name ÎļþÃû
// * @param uri ÎļþµØÖ·
// */
// public void add(String name,String uri){
// SQLiteDatabase db=helper.getWritableDatabase();
// db.execSQL("insert into playlist (name,uri) values(?,?)",new Object[]{name,uri});
// db.close();
// }
// /**
// * ²éѯËùÓиèÇúÁбí
// * @return ËùÓÐÔÚ¿â¸èÇú
// */
// public List<Song> selectAll(){
// SQLiteDatabase db=helper.getReadableDatabase();
// Cursor cursor=db.rawQuery("select * from playlist", null);
// List<Song> songs=new ArrayList<Song>();
// while(cursor.moveToNext()){
// int id=cursor.getInt(cursor.getColumnIndex("id"));
// String name=cursor.getString(cursor.getColumnIndex("name"));
// String uri=cursor.getString(cursor.getColumnIndex("uri"));
// Song song=new Song(id, name,uri );
// songs.add(song);
// }
// cursor.close();
// db.close();
// return songs;
// }
// public void clear(){
// SQLiteDatabase db=helper.getWritableDatabase();
// db.execSQL("delete from playlist");//Çå¿Õ±í
// db.execSQL("update sqlite_sequence set seq=0 where name='playlist'");//ÖØÖÃid×ÔÔö¶Î
// db.close();
// }
// }
//
// Path: LightPlayer/src/com/sequarius/lightplayer/tools/FileFilterBySuffix.java
// public class FileFilterBySuffix implements FileFilter {
//
// private String suffix;
//
// public FileFilterBySuffix(String suffix) {
// super();
// this.suffix = suffix;
// }
//
// @Override
// public boolean accept(File pathname) {
//
// return pathname.getName().endsWith(suffix);
// }
// }
//
// Path: LightPlayer/src/com/sequarius/lightplayer/tools/Queue.java
// public class Queue<E> {
// private LinkedList<E> link;
//
// /**
// * ÌṩÁ˹¹Ôì¶ÓÁжÔÏóµÄ¹¹ÔìÆ÷¡£
// */
// public Queue() {
// link = new LinkedList<E>();
// }
//
// /**
// * Ìí¼ÓÔªËØµÄ·½·¨¡£
// */
// public void myAdd(E obj) {
// link.addFirst(obj);
// }
//
// /**
// * »ñÈ¡µÄ·½·¨¡£
// */
// public E myGet() {
// return link.removeLast();
// }
//
// /**
// * Åж϶ÓÁÐÊÇ·ñÓÐÔªËØ¡£
// */
// public boolean isNull() {
// return link.isEmpty();
// }
// }
// Path: LightPlayer/src/com/sequarius/lightplayer/SearchMusicActivity.java
import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList;
import java.util.List;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
import com.sequarius.lightplayer.database.PlayListDAO;
import com.sequarius.lightplayer.tools.FileFilterBySuffix;
import com.sequarius.lightplayer.tools.Queue;
package com.sequarius.lightplayer;
public class SearchMusicActivity extends Activity {
PlayListDAO mPlayListDAO;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
mPlayListDAO = new PlayListDAO(this);
setContentView(R.layout.layout_search_music);
Button button = (Button) findViewById(R.id.button_search_music);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
int count = searchMusicFile();
Toast.makeText(SearchMusicActivity.this,
"ɨÃèÍê±Ï,¹²ÕÒµ½" + count + "¸öÒôÀÖÎļþ¡£", Toast.LENGTH_SHORT)
.show();
finish();
}
});
}
/**
* ±éÀúSD¿¨ËùÓÐMP3Îļþ
*
* @return ÕÒµ½µÄMP3ÊýÁ¿
*/
public int searchMusicFile() {
// ɨÃèĿ¼
File dir = new File("sdcard/");
// ¹ýÂËÆ÷
FileFilter filter = new FileFilterBySuffix("mp3");
// ´¢´æ·ûºÏÒªÇóµÄÎļþ
List<File> list = new ArrayList<File>();
// getFileList(dir, filter, list);
| Queue<File> queue = new Queue<File>();
|
sequarius/SequariusToys | GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/presenter/MainPresenter.java | // Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/module/main/MainView.java
// public interface MainView {
// void notifyDataSetChanged();
//
// void initView();
//
// void makeCommonSnake(String message);
//
// void setProgressBarVisible(boolean visible);
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/task/ScanHandler.java
// public abstract class ScanHandler {
// public static final String SUFFIX_JPG = "jpg";
// private int taskCount;
//
// private FileFilter fileFilter;
//
// private long mStartTime=Long.MIN_VALUE;
//
// public long getStartTime() {
// return mStartTime;
// }
//
// public ScanHandler() {
// fileFilter=new FileFilterBySuffix(SUFFIX_JPG);
// mStartTime=System.currentTimeMillis();
// }
//
// public FileFilter getFileFilter() {
// return fileFilter;
// }
//
// public abstract void onFinish(long finishTime);
//
// public synchronized void addTaskCount() {
// taskCount += 1;
// }
//
// public synchronized int devideTaskCount() {
// taskCount -= 1;
// return taskCount;
// }
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/task/ScanImageFileTask.java
// public class ScanImageFileTask implements Runnable {
//
// private File mDirectory;
// private ExecutorService mExecutor;
// private List<File> mResultFileSet;
// private ScanHandler mHandler;
//
// public ScanImageFileTask(File directory, ExecutorService executor, List<File> resultFileSet, ScanHandler handler) {
// this.mHandler = handler;
// handler.addTaskCount();
// this.mDirectory = directory;
// this.mExecutor = executor;
// this.mResultFileSet = resultFileSet;
// }
//
// @Override
// public void run() {
// File[] files = mDirectory.listFiles();
// if (files != null) {
// for (File file : files) {
// if (file.isDirectory()) {
// mExecutor.execute(new ScanImageFileTask(file, mExecutor, mResultFileSet, mHandler));
// } else {
// if (mHandler.getFileFilter().accept(file)) {
// mResultFileSet.add(file);
// }
// }
// }
// }
// //traversal finish
// if (mHandler.devideTaskCount() == 0) {
// mHandler.onFinish(System.currentTimeMillis());
// }
// }
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/utils/FileFilterBySuffix.java
// public class FileFilterBySuffix implements FileFilter {
//
// private String suffix;
//
// public FileFilterBySuffix(String suffix) {
// super();
// this.suffix = suffix;
// }
//
// @Override
// public boolean accept(File pathname) {
//
// return pathname.getName().endsWith(suffix);
// }
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/utils/SimpleQueue.java
// public class SimpleQueue<E> {
// private LinkedList<E> link;
//
//
// public SimpleQueue() {
// link = new LinkedList<E>();
// }
//
// public void add(E obj) {
// link.addFirst(obj);
// }
//
//
// public E peek() {
// return link.removeLast();
// }
//
//
// public boolean isEmpty() {
// return link.isEmpty();
// }
// }
| import android.content.Context;
import android.os.Environment;
import java.io.File;
import java.io.FileFilter;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import gov.sequarius.toys.gallery.R;
import gov.sequarius.toys.gallery.module.main.MainView;
import gov.sequarius.toys.gallery.task.ScanHandler;
import gov.sequarius.toys.gallery.task.ScanImageFileTask;
import gov.sequarius.toys.gallery.utils.FileFilterBySuffix;
import gov.sequarius.toys.gallery.utils.SimpleQueue;
| package gov.sequarius.toys.gallery.presenter;
/**
* Simple presenter for service
* Created by Sequarius on 2016/5/10.
*/
public class MainPresenter {
private static final int POOL_SIZE = 15;
private static final int CORE_POOL_SIZE = 10;
private static final int KEEP_ALIVE_TIME = 1;
private Context mContext;
| // Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/module/main/MainView.java
// public interface MainView {
// void notifyDataSetChanged();
//
// void initView();
//
// void makeCommonSnake(String message);
//
// void setProgressBarVisible(boolean visible);
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/task/ScanHandler.java
// public abstract class ScanHandler {
// public static final String SUFFIX_JPG = "jpg";
// private int taskCount;
//
// private FileFilter fileFilter;
//
// private long mStartTime=Long.MIN_VALUE;
//
// public long getStartTime() {
// return mStartTime;
// }
//
// public ScanHandler() {
// fileFilter=new FileFilterBySuffix(SUFFIX_JPG);
// mStartTime=System.currentTimeMillis();
// }
//
// public FileFilter getFileFilter() {
// return fileFilter;
// }
//
// public abstract void onFinish(long finishTime);
//
// public synchronized void addTaskCount() {
// taskCount += 1;
// }
//
// public synchronized int devideTaskCount() {
// taskCount -= 1;
// return taskCount;
// }
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/task/ScanImageFileTask.java
// public class ScanImageFileTask implements Runnable {
//
// private File mDirectory;
// private ExecutorService mExecutor;
// private List<File> mResultFileSet;
// private ScanHandler mHandler;
//
// public ScanImageFileTask(File directory, ExecutorService executor, List<File> resultFileSet, ScanHandler handler) {
// this.mHandler = handler;
// handler.addTaskCount();
// this.mDirectory = directory;
// this.mExecutor = executor;
// this.mResultFileSet = resultFileSet;
// }
//
// @Override
// public void run() {
// File[] files = mDirectory.listFiles();
// if (files != null) {
// for (File file : files) {
// if (file.isDirectory()) {
// mExecutor.execute(new ScanImageFileTask(file, mExecutor, mResultFileSet, mHandler));
// } else {
// if (mHandler.getFileFilter().accept(file)) {
// mResultFileSet.add(file);
// }
// }
// }
// }
// //traversal finish
// if (mHandler.devideTaskCount() == 0) {
// mHandler.onFinish(System.currentTimeMillis());
// }
// }
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/utils/FileFilterBySuffix.java
// public class FileFilterBySuffix implements FileFilter {
//
// private String suffix;
//
// public FileFilterBySuffix(String suffix) {
// super();
// this.suffix = suffix;
// }
//
// @Override
// public boolean accept(File pathname) {
//
// return pathname.getName().endsWith(suffix);
// }
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/utils/SimpleQueue.java
// public class SimpleQueue<E> {
// private LinkedList<E> link;
//
//
// public SimpleQueue() {
// link = new LinkedList<E>();
// }
//
// public void add(E obj) {
// link.addFirst(obj);
// }
//
//
// public E peek() {
// return link.removeLast();
// }
//
//
// public boolean isEmpty() {
// return link.isEmpty();
// }
// }
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/presenter/MainPresenter.java
import android.content.Context;
import android.os.Environment;
import java.io.File;
import java.io.FileFilter;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import gov.sequarius.toys.gallery.R;
import gov.sequarius.toys.gallery.module.main.MainView;
import gov.sequarius.toys.gallery.task.ScanHandler;
import gov.sequarius.toys.gallery.task.ScanImageFileTask;
import gov.sequarius.toys.gallery.utils.FileFilterBySuffix;
import gov.sequarius.toys.gallery.utils.SimpleQueue;
package gov.sequarius.toys.gallery.presenter;
/**
* Simple presenter for service
* Created by Sequarius on 2016/5/10.
*/
public class MainPresenter {
private static final int POOL_SIZE = 15;
private static final int CORE_POOL_SIZE = 10;
private static final int KEEP_ALIVE_TIME = 1;
private Context mContext;
| private MainView mView;
|
sequarius/SequariusToys | GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/presenter/MainPresenter.java | // Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/module/main/MainView.java
// public interface MainView {
// void notifyDataSetChanged();
//
// void initView();
//
// void makeCommonSnake(String message);
//
// void setProgressBarVisible(boolean visible);
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/task/ScanHandler.java
// public abstract class ScanHandler {
// public static final String SUFFIX_JPG = "jpg";
// private int taskCount;
//
// private FileFilter fileFilter;
//
// private long mStartTime=Long.MIN_VALUE;
//
// public long getStartTime() {
// return mStartTime;
// }
//
// public ScanHandler() {
// fileFilter=new FileFilterBySuffix(SUFFIX_JPG);
// mStartTime=System.currentTimeMillis();
// }
//
// public FileFilter getFileFilter() {
// return fileFilter;
// }
//
// public abstract void onFinish(long finishTime);
//
// public synchronized void addTaskCount() {
// taskCount += 1;
// }
//
// public synchronized int devideTaskCount() {
// taskCount -= 1;
// return taskCount;
// }
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/task/ScanImageFileTask.java
// public class ScanImageFileTask implements Runnable {
//
// private File mDirectory;
// private ExecutorService mExecutor;
// private List<File> mResultFileSet;
// private ScanHandler mHandler;
//
// public ScanImageFileTask(File directory, ExecutorService executor, List<File> resultFileSet, ScanHandler handler) {
// this.mHandler = handler;
// handler.addTaskCount();
// this.mDirectory = directory;
// this.mExecutor = executor;
// this.mResultFileSet = resultFileSet;
// }
//
// @Override
// public void run() {
// File[] files = mDirectory.listFiles();
// if (files != null) {
// for (File file : files) {
// if (file.isDirectory()) {
// mExecutor.execute(new ScanImageFileTask(file, mExecutor, mResultFileSet, mHandler));
// } else {
// if (mHandler.getFileFilter().accept(file)) {
// mResultFileSet.add(file);
// }
// }
// }
// }
// //traversal finish
// if (mHandler.devideTaskCount() == 0) {
// mHandler.onFinish(System.currentTimeMillis());
// }
// }
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/utils/FileFilterBySuffix.java
// public class FileFilterBySuffix implements FileFilter {
//
// private String suffix;
//
// public FileFilterBySuffix(String suffix) {
// super();
// this.suffix = suffix;
// }
//
// @Override
// public boolean accept(File pathname) {
//
// return pathname.getName().endsWith(suffix);
// }
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/utils/SimpleQueue.java
// public class SimpleQueue<E> {
// private LinkedList<E> link;
//
//
// public SimpleQueue() {
// link = new LinkedList<E>();
// }
//
// public void add(E obj) {
// link.addFirst(obj);
// }
//
//
// public E peek() {
// return link.removeLast();
// }
//
//
// public boolean isEmpty() {
// return link.isEmpty();
// }
// }
| import android.content.Context;
import android.os.Environment;
import java.io.File;
import java.io.FileFilter;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import gov.sequarius.toys.gallery.R;
import gov.sequarius.toys.gallery.module.main.MainView;
import gov.sequarius.toys.gallery.task.ScanHandler;
import gov.sequarius.toys.gallery.task.ScanImageFileTask;
import gov.sequarius.toys.gallery.utils.FileFilterBySuffix;
import gov.sequarius.toys.gallery.utils.SimpleQueue;
| package gov.sequarius.toys.gallery.presenter;
/**
* Simple presenter for service
* Created by Sequarius on 2016/5/10.
*/
public class MainPresenter {
private static final int POOL_SIZE = 15;
private static final int CORE_POOL_SIZE = 10;
private static final int KEEP_ALIVE_TIME = 1;
private Context mContext;
private MainView mView;
private List<File> mDataSet;
public MainPresenter(Context mContext, MainView mView, List<File> mDataSet) {
this.mContext = mContext;
this.mView = mView;
this.mDataSet = mDataSet;
}
/**
* get image files by thread pool
*/
public void getExternalImageFile() {
//create thread pool
final ExecutorService executorService =
new ThreadPoolExecutor(
CORE_POOL_SIZE,
POOL_SIZE,
KEEP_ALIVE_TIME,
TimeUnit.MINUTES,
new LinkedBlockingQueue<Runnable>(),
new ThreadPoolExecutor.CallerRunsPolicy());
//get external storage dir
File externalCacheDir = Environment.getExternalStorageDirectory();
mDataSet.clear();
//start traversal dirs
| // Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/module/main/MainView.java
// public interface MainView {
// void notifyDataSetChanged();
//
// void initView();
//
// void makeCommonSnake(String message);
//
// void setProgressBarVisible(boolean visible);
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/task/ScanHandler.java
// public abstract class ScanHandler {
// public static final String SUFFIX_JPG = "jpg";
// private int taskCount;
//
// private FileFilter fileFilter;
//
// private long mStartTime=Long.MIN_VALUE;
//
// public long getStartTime() {
// return mStartTime;
// }
//
// public ScanHandler() {
// fileFilter=new FileFilterBySuffix(SUFFIX_JPG);
// mStartTime=System.currentTimeMillis();
// }
//
// public FileFilter getFileFilter() {
// return fileFilter;
// }
//
// public abstract void onFinish(long finishTime);
//
// public synchronized void addTaskCount() {
// taskCount += 1;
// }
//
// public synchronized int devideTaskCount() {
// taskCount -= 1;
// return taskCount;
// }
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/task/ScanImageFileTask.java
// public class ScanImageFileTask implements Runnable {
//
// private File mDirectory;
// private ExecutorService mExecutor;
// private List<File> mResultFileSet;
// private ScanHandler mHandler;
//
// public ScanImageFileTask(File directory, ExecutorService executor, List<File> resultFileSet, ScanHandler handler) {
// this.mHandler = handler;
// handler.addTaskCount();
// this.mDirectory = directory;
// this.mExecutor = executor;
// this.mResultFileSet = resultFileSet;
// }
//
// @Override
// public void run() {
// File[] files = mDirectory.listFiles();
// if (files != null) {
// for (File file : files) {
// if (file.isDirectory()) {
// mExecutor.execute(new ScanImageFileTask(file, mExecutor, mResultFileSet, mHandler));
// } else {
// if (mHandler.getFileFilter().accept(file)) {
// mResultFileSet.add(file);
// }
// }
// }
// }
// //traversal finish
// if (mHandler.devideTaskCount() == 0) {
// mHandler.onFinish(System.currentTimeMillis());
// }
// }
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/utils/FileFilterBySuffix.java
// public class FileFilterBySuffix implements FileFilter {
//
// private String suffix;
//
// public FileFilterBySuffix(String suffix) {
// super();
// this.suffix = suffix;
// }
//
// @Override
// public boolean accept(File pathname) {
//
// return pathname.getName().endsWith(suffix);
// }
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/utils/SimpleQueue.java
// public class SimpleQueue<E> {
// private LinkedList<E> link;
//
//
// public SimpleQueue() {
// link = new LinkedList<E>();
// }
//
// public void add(E obj) {
// link.addFirst(obj);
// }
//
//
// public E peek() {
// return link.removeLast();
// }
//
//
// public boolean isEmpty() {
// return link.isEmpty();
// }
// }
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/presenter/MainPresenter.java
import android.content.Context;
import android.os.Environment;
import java.io.File;
import java.io.FileFilter;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import gov.sequarius.toys.gallery.R;
import gov.sequarius.toys.gallery.module.main.MainView;
import gov.sequarius.toys.gallery.task.ScanHandler;
import gov.sequarius.toys.gallery.task.ScanImageFileTask;
import gov.sequarius.toys.gallery.utils.FileFilterBySuffix;
import gov.sequarius.toys.gallery.utils.SimpleQueue;
package gov.sequarius.toys.gallery.presenter;
/**
* Simple presenter for service
* Created by Sequarius on 2016/5/10.
*/
public class MainPresenter {
private static final int POOL_SIZE = 15;
private static final int CORE_POOL_SIZE = 10;
private static final int KEEP_ALIVE_TIME = 1;
private Context mContext;
private MainView mView;
private List<File> mDataSet;
public MainPresenter(Context mContext, MainView mView, List<File> mDataSet) {
this.mContext = mContext;
this.mView = mView;
this.mDataSet = mDataSet;
}
/**
* get image files by thread pool
*/
public void getExternalImageFile() {
//create thread pool
final ExecutorService executorService =
new ThreadPoolExecutor(
CORE_POOL_SIZE,
POOL_SIZE,
KEEP_ALIVE_TIME,
TimeUnit.MINUTES,
new LinkedBlockingQueue<Runnable>(),
new ThreadPoolExecutor.CallerRunsPolicy());
//get external storage dir
File externalCacheDir = Environment.getExternalStorageDirectory();
mDataSet.clear();
//start traversal dirs
| executorService.execute(new ScanImageFileTask(externalCacheDir, executorService,
|
sequarius/SequariusToys | GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/presenter/MainPresenter.java | // Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/module/main/MainView.java
// public interface MainView {
// void notifyDataSetChanged();
//
// void initView();
//
// void makeCommonSnake(String message);
//
// void setProgressBarVisible(boolean visible);
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/task/ScanHandler.java
// public abstract class ScanHandler {
// public static final String SUFFIX_JPG = "jpg";
// private int taskCount;
//
// private FileFilter fileFilter;
//
// private long mStartTime=Long.MIN_VALUE;
//
// public long getStartTime() {
// return mStartTime;
// }
//
// public ScanHandler() {
// fileFilter=new FileFilterBySuffix(SUFFIX_JPG);
// mStartTime=System.currentTimeMillis();
// }
//
// public FileFilter getFileFilter() {
// return fileFilter;
// }
//
// public abstract void onFinish(long finishTime);
//
// public synchronized void addTaskCount() {
// taskCount += 1;
// }
//
// public synchronized int devideTaskCount() {
// taskCount -= 1;
// return taskCount;
// }
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/task/ScanImageFileTask.java
// public class ScanImageFileTask implements Runnable {
//
// private File mDirectory;
// private ExecutorService mExecutor;
// private List<File> mResultFileSet;
// private ScanHandler mHandler;
//
// public ScanImageFileTask(File directory, ExecutorService executor, List<File> resultFileSet, ScanHandler handler) {
// this.mHandler = handler;
// handler.addTaskCount();
// this.mDirectory = directory;
// this.mExecutor = executor;
// this.mResultFileSet = resultFileSet;
// }
//
// @Override
// public void run() {
// File[] files = mDirectory.listFiles();
// if (files != null) {
// for (File file : files) {
// if (file.isDirectory()) {
// mExecutor.execute(new ScanImageFileTask(file, mExecutor, mResultFileSet, mHandler));
// } else {
// if (mHandler.getFileFilter().accept(file)) {
// mResultFileSet.add(file);
// }
// }
// }
// }
// //traversal finish
// if (mHandler.devideTaskCount() == 0) {
// mHandler.onFinish(System.currentTimeMillis());
// }
// }
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/utils/FileFilterBySuffix.java
// public class FileFilterBySuffix implements FileFilter {
//
// private String suffix;
//
// public FileFilterBySuffix(String suffix) {
// super();
// this.suffix = suffix;
// }
//
// @Override
// public boolean accept(File pathname) {
//
// return pathname.getName().endsWith(suffix);
// }
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/utils/SimpleQueue.java
// public class SimpleQueue<E> {
// private LinkedList<E> link;
//
//
// public SimpleQueue() {
// link = new LinkedList<E>();
// }
//
// public void add(E obj) {
// link.addFirst(obj);
// }
//
//
// public E peek() {
// return link.removeLast();
// }
//
//
// public boolean isEmpty() {
// return link.isEmpty();
// }
// }
| import android.content.Context;
import android.os.Environment;
import java.io.File;
import java.io.FileFilter;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import gov.sequarius.toys.gallery.R;
import gov.sequarius.toys.gallery.module.main.MainView;
import gov.sequarius.toys.gallery.task.ScanHandler;
import gov.sequarius.toys.gallery.task.ScanImageFileTask;
import gov.sequarius.toys.gallery.utils.FileFilterBySuffix;
import gov.sequarius.toys.gallery.utils.SimpleQueue;
| package gov.sequarius.toys.gallery.presenter;
/**
* Simple presenter for service
* Created by Sequarius on 2016/5/10.
*/
public class MainPresenter {
private static final int POOL_SIZE = 15;
private static final int CORE_POOL_SIZE = 10;
private static final int KEEP_ALIVE_TIME = 1;
private Context mContext;
private MainView mView;
private List<File> mDataSet;
public MainPresenter(Context mContext, MainView mView, List<File> mDataSet) {
this.mContext = mContext;
this.mView = mView;
this.mDataSet = mDataSet;
}
/**
* get image files by thread pool
*/
public void getExternalImageFile() {
//create thread pool
final ExecutorService executorService =
new ThreadPoolExecutor(
CORE_POOL_SIZE,
POOL_SIZE,
KEEP_ALIVE_TIME,
TimeUnit.MINUTES,
new LinkedBlockingQueue<Runnable>(),
new ThreadPoolExecutor.CallerRunsPolicy());
//get external storage dir
File externalCacheDir = Environment.getExternalStorageDirectory();
mDataSet.clear();
//start traversal dirs
executorService.execute(new ScanImageFileTask(externalCacheDir, executorService,
| // Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/module/main/MainView.java
// public interface MainView {
// void notifyDataSetChanged();
//
// void initView();
//
// void makeCommonSnake(String message);
//
// void setProgressBarVisible(boolean visible);
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/task/ScanHandler.java
// public abstract class ScanHandler {
// public static final String SUFFIX_JPG = "jpg";
// private int taskCount;
//
// private FileFilter fileFilter;
//
// private long mStartTime=Long.MIN_VALUE;
//
// public long getStartTime() {
// return mStartTime;
// }
//
// public ScanHandler() {
// fileFilter=new FileFilterBySuffix(SUFFIX_JPG);
// mStartTime=System.currentTimeMillis();
// }
//
// public FileFilter getFileFilter() {
// return fileFilter;
// }
//
// public abstract void onFinish(long finishTime);
//
// public synchronized void addTaskCount() {
// taskCount += 1;
// }
//
// public synchronized int devideTaskCount() {
// taskCount -= 1;
// return taskCount;
// }
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/task/ScanImageFileTask.java
// public class ScanImageFileTask implements Runnable {
//
// private File mDirectory;
// private ExecutorService mExecutor;
// private List<File> mResultFileSet;
// private ScanHandler mHandler;
//
// public ScanImageFileTask(File directory, ExecutorService executor, List<File> resultFileSet, ScanHandler handler) {
// this.mHandler = handler;
// handler.addTaskCount();
// this.mDirectory = directory;
// this.mExecutor = executor;
// this.mResultFileSet = resultFileSet;
// }
//
// @Override
// public void run() {
// File[] files = mDirectory.listFiles();
// if (files != null) {
// for (File file : files) {
// if (file.isDirectory()) {
// mExecutor.execute(new ScanImageFileTask(file, mExecutor, mResultFileSet, mHandler));
// } else {
// if (mHandler.getFileFilter().accept(file)) {
// mResultFileSet.add(file);
// }
// }
// }
// }
// //traversal finish
// if (mHandler.devideTaskCount() == 0) {
// mHandler.onFinish(System.currentTimeMillis());
// }
// }
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/utils/FileFilterBySuffix.java
// public class FileFilterBySuffix implements FileFilter {
//
// private String suffix;
//
// public FileFilterBySuffix(String suffix) {
// super();
// this.suffix = suffix;
// }
//
// @Override
// public boolean accept(File pathname) {
//
// return pathname.getName().endsWith(suffix);
// }
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/utils/SimpleQueue.java
// public class SimpleQueue<E> {
// private LinkedList<E> link;
//
//
// public SimpleQueue() {
// link = new LinkedList<E>();
// }
//
// public void add(E obj) {
// link.addFirst(obj);
// }
//
//
// public E peek() {
// return link.removeLast();
// }
//
//
// public boolean isEmpty() {
// return link.isEmpty();
// }
// }
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/presenter/MainPresenter.java
import android.content.Context;
import android.os.Environment;
import java.io.File;
import java.io.FileFilter;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import gov.sequarius.toys.gallery.R;
import gov.sequarius.toys.gallery.module.main.MainView;
import gov.sequarius.toys.gallery.task.ScanHandler;
import gov.sequarius.toys.gallery.task.ScanImageFileTask;
import gov.sequarius.toys.gallery.utils.FileFilterBySuffix;
import gov.sequarius.toys.gallery.utils.SimpleQueue;
package gov.sequarius.toys.gallery.presenter;
/**
* Simple presenter for service
* Created by Sequarius on 2016/5/10.
*/
public class MainPresenter {
private static final int POOL_SIZE = 15;
private static final int CORE_POOL_SIZE = 10;
private static final int KEEP_ALIVE_TIME = 1;
private Context mContext;
private MainView mView;
private List<File> mDataSet;
public MainPresenter(Context mContext, MainView mView, List<File> mDataSet) {
this.mContext = mContext;
this.mView = mView;
this.mDataSet = mDataSet;
}
/**
* get image files by thread pool
*/
public void getExternalImageFile() {
//create thread pool
final ExecutorService executorService =
new ThreadPoolExecutor(
CORE_POOL_SIZE,
POOL_SIZE,
KEEP_ALIVE_TIME,
TimeUnit.MINUTES,
new LinkedBlockingQueue<Runnable>(),
new ThreadPoolExecutor.CallerRunsPolicy());
//get external storage dir
File externalCacheDir = Environment.getExternalStorageDirectory();
mDataSet.clear();
//start traversal dirs
executorService.execute(new ScanImageFileTask(externalCacheDir, executorService,
| mDataSet, new ScanHandler() {
|
sequarius/SequariusToys | GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/presenter/MainPresenter.java | // Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/module/main/MainView.java
// public interface MainView {
// void notifyDataSetChanged();
//
// void initView();
//
// void makeCommonSnake(String message);
//
// void setProgressBarVisible(boolean visible);
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/task/ScanHandler.java
// public abstract class ScanHandler {
// public static final String SUFFIX_JPG = "jpg";
// private int taskCount;
//
// private FileFilter fileFilter;
//
// private long mStartTime=Long.MIN_VALUE;
//
// public long getStartTime() {
// return mStartTime;
// }
//
// public ScanHandler() {
// fileFilter=new FileFilterBySuffix(SUFFIX_JPG);
// mStartTime=System.currentTimeMillis();
// }
//
// public FileFilter getFileFilter() {
// return fileFilter;
// }
//
// public abstract void onFinish(long finishTime);
//
// public synchronized void addTaskCount() {
// taskCount += 1;
// }
//
// public synchronized int devideTaskCount() {
// taskCount -= 1;
// return taskCount;
// }
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/task/ScanImageFileTask.java
// public class ScanImageFileTask implements Runnable {
//
// private File mDirectory;
// private ExecutorService mExecutor;
// private List<File> mResultFileSet;
// private ScanHandler mHandler;
//
// public ScanImageFileTask(File directory, ExecutorService executor, List<File> resultFileSet, ScanHandler handler) {
// this.mHandler = handler;
// handler.addTaskCount();
// this.mDirectory = directory;
// this.mExecutor = executor;
// this.mResultFileSet = resultFileSet;
// }
//
// @Override
// public void run() {
// File[] files = mDirectory.listFiles();
// if (files != null) {
// for (File file : files) {
// if (file.isDirectory()) {
// mExecutor.execute(new ScanImageFileTask(file, mExecutor, mResultFileSet, mHandler));
// } else {
// if (mHandler.getFileFilter().accept(file)) {
// mResultFileSet.add(file);
// }
// }
// }
// }
// //traversal finish
// if (mHandler.devideTaskCount() == 0) {
// mHandler.onFinish(System.currentTimeMillis());
// }
// }
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/utils/FileFilterBySuffix.java
// public class FileFilterBySuffix implements FileFilter {
//
// private String suffix;
//
// public FileFilterBySuffix(String suffix) {
// super();
// this.suffix = suffix;
// }
//
// @Override
// public boolean accept(File pathname) {
//
// return pathname.getName().endsWith(suffix);
// }
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/utils/SimpleQueue.java
// public class SimpleQueue<E> {
// private LinkedList<E> link;
//
//
// public SimpleQueue() {
// link = new LinkedList<E>();
// }
//
// public void add(E obj) {
// link.addFirst(obj);
// }
//
//
// public E peek() {
// return link.removeLast();
// }
//
//
// public boolean isEmpty() {
// return link.isEmpty();
// }
// }
| import android.content.Context;
import android.os.Environment;
import java.io.File;
import java.io.FileFilter;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import gov.sequarius.toys.gallery.R;
import gov.sequarius.toys.gallery.module.main.MainView;
import gov.sequarius.toys.gallery.task.ScanHandler;
import gov.sequarius.toys.gallery.task.ScanImageFileTask;
import gov.sequarius.toys.gallery.utils.FileFilterBySuffix;
import gov.sequarius.toys.gallery.utils.SimpleQueue;
| //start traversal dirs
executorService.execute(new ScanImageFileTask(externalCacheDir, executorService,
mDataSet, new ScanHandler() {
@Override
//simple call back when traversal completed
public void onFinish(long finishTime) {
mView.notifyDataSetChanged();
mView.makeCommonSnake(mContext.getString(R.string.message_format_load_result,
mDataSet.size(), finishTime - getStartTime()));
mView.setProgressBarVisible(false);
//shutdown thread pool
executorService.shutdown();
}
}));
}
/**
* get image files by single thread
*/
public void getExternalImageBySingleThread() {
mView.setProgressBarVisible(true);
new singleThreadScanTask().start();
}
private class singleThreadScanTask extends Thread {
@Override
public void run() {
File externalCacheDir = Environment.getExternalStorageDirectory();
mDataSet.clear();
long startTime = System.currentTimeMillis();
| // Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/module/main/MainView.java
// public interface MainView {
// void notifyDataSetChanged();
//
// void initView();
//
// void makeCommonSnake(String message);
//
// void setProgressBarVisible(boolean visible);
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/task/ScanHandler.java
// public abstract class ScanHandler {
// public static final String SUFFIX_JPG = "jpg";
// private int taskCount;
//
// private FileFilter fileFilter;
//
// private long mStartTime=Long.MIN_VALUE;
//
// public long getStartTime() {
// return mStartTime;
// }
//
// public ScanHandler() {
// fileFilter=new FileFilterBySuffix(SUFFIX_JPG);
// mStartTime=System.currentTimeMillis();
// }
//
// public FileFilter getFileFilter() {
// return fileFilter;
// }
//
// public abstract void onFinish(long finishTime);
//
// public synchronized void addTaskCount() {
// taskCount += 1;
// }
//
// public synchronized int devideTaskCount() {
// taskCount -= 1;
// return taskCount;
// }
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/task/ScanImageFileTask.java
// public class ScanImageFileTask implements Runnable {
//
// private File mDirectory;
// private ExecutorService mExecutor;
// private List<File> mResultFileSet;
// private ScanHandler mHandler;
//
// public ScanImageFileTask(File directory, ExecutorService executor, List<File> resultFileSet, ScanHandler handler) {
// this.mHandler = handler;
// handler.addTaskCount();
// this.mDirectory = directory;
// this.mExecutor = executor;
// this.mResultFileSet = resultFileSet;
// }
//
// @Override
// public void run() {
// File[] files = mDirectory.listFiles();
// if (files != null) {
// for (File file : files) {
// if (file.isDirectory()) {
// mExecutor.execute(new ScanImageFileTask(file, mExecutor, mResultFileSet, mHandler));
// } else {
// if (mHandler.getFileFilter().accept(file)) {
// mResultFileSet.add(file);
// }
// }
// }
// }
// //traversal finish
// if (mHandler.devideTaskCount() == 0) {
// mHandler.onFinish(System.currentTimeMillis());
// }
// }
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/utils/FileFilterBySuffix.java
// public class FileFilterBySuffix implements FileFilter {
//
// private String suffix;
//
// public FileFilterBySuffix(String suffix) {
// super();
// this.suffix = suffix;
// }
//
// @Override
// public boolean accept(File pathname) {
//
// return pathname.getName().endsWith(suffix);
// }
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/utils/SimpleQueue.java
// public class SimpleQueue<E> {
// private LinkedList<E> link;
//
//
// public SimpleQueue() {
// link = new LinkedList<E>();
// }
//
// public void add(E obj) {
// link.addFirst(obj);
// }
//
//
// public E peek() {
// return link.removeLast();
// }
//
//
// public boolean isEmpty() {
// return link.isEmpty();
// }
// }
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/presenter/MainPresenter.java
import android.content.Context;
import android.os.Environment;
import java.io.File;
import java.io.FileFilter;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import gov.sequarius.toys.gallery.R;
import gov.sequarius.toys.gallery.module.main.MainView;
import gov.sequarius.toys.gallery.task.ScanHandler;
import gov.sequarius.toys.gallery.task.ScanImageFileTask;
import gov.sequarius.toys.gallery.utils.FileFilterBySuffix;
import gov.sequarius.toys.gallery.utils.SimpleQueue;
//start traversal dirs
executorService.execute(new ScanImageFileTask(externalCacheDir, executorService,
mDataSet, new ScanHandler() {
@Override
//simple call back when traversal completed
public void onFinish(long finishTime) {
mView.notifyDataSetChanged();
mView.makeCommonSnake(mContext.getString(R.string.message_format_load_result,
mDataSet.size(), finishTime - getStartTime()));
mView.setProgressBarVisible(false);
//shutdown thread pool
executorService.shutdown();
}
}));
}
/**
* get image files by single thread
*/
public void getExternalImageBySingleThread() {
mView.setProgressBarVisible(true);
new singleThreadScanTask().start();
}
private class singleThreadScanTask extends Thread {
@Override
public void run() {
File externalCacheDir = Environment.getExternalStorageDirectory();
mDataSet.clear();
long startTime = System.currentTimeMillis();
| FileFilter filter = new FileFilterBySuffix(ScanHandler.SUFFIX_JPG);
|
sequarius/SequariusToys | GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/presenter/MainPresenter.java | // Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/module/main/MainView.java
// public interface MainView {
// void notifyDataSetChanged();
//
// void initView();
//
// void makeCommonSnake(String message);
//
// void setProgressBarVisible(boolean visible);
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/task/ScanHandler.java
// public abstract class ScanHandler {
// public static final String SUFFIX_JPG = "jpg";
// private int taskCount;
//
// private FileFilter fileFilter;
//
// private long mStartTime=Long.MIN_VALUE;
//
// public long getStartTime() {
// return mStartTime;
// }
//
// public ScanHandler() {
// fileFilter=new FileFilterBySuffix(SUFFIX_JPG);
// mStartTime=System.currentTimeMillis();
// }
//
// public FileFilter getFileFilter() {
// return fileFilter;
// }
//
// public abstract void onFinish(long finishTime);
//
// public synchronized void addTaskCount() {
// taskCount += 1;
// }
//
// public synchronized int devideTaskCount() {
// taskCount -= 1;
// return taskCount;
// }
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/task/ScanImageFileTask.java
// public class ScanImageFileTask implements Runnable {
//
// private File mDirectory;
// private ExecutorService mExecutor;
// private List<File> mResultFileSet;
// private ScanHandler mHandler;
//
// public ScanImageFileTask(File directory, ExecutorService executor, List<File> resultFileSet, ScanHandler handler) {
// this.mHandler = handler;
// handler.addTaskCount();
// this.mDirectory = directory;
// this.mExecutor = executor;
// this.mResultFileSet = resultFileSet;
// }
//
// @Override
// public void run() {
// File[] files = mDirectory.listFiles();
// if (files != null) {
// for (File file : files) {
// if (file.isDirectory()) {
// mExecutor.execute(new ScanImageFileTask(file, mExecutor, mResultFileSet, mHandler));
// } else {
// if (mHandler.getFileFilter().accept(file)) {
// mResultFileSet.add(file);
// }
// }
// }
// }
// //traversal finish
// if (mHandler.devideTaskCount() == 0) {
// mHandler.onFinish(System.currentTimeMillis());
// }
// }
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/utils/FileFilterBySuffix.java
// public class FileFilterBySuffix implements FileFilter {
//
// private String suffix;
//
// public FileFilterBySuffix(String suffix) {
// super();
// this.suffix = suffix;
// }
//
// @Override
// public boolean accept(File pathname) {
//
// return pathname.getName().endsWith(suffix);
// }
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/utils/SimpleQueue.java
// public class SimpleQueue<E> {
// private LinkedList<E> link;
//
//
// public SimpleQueue() {
// link = new LinkedList<E>();
// }
//
// public void add(E obj) {
// link.addFirst(obj);
// }
//
//
// public E peek() {
// return link.removeLast();
// }
//
//
// public boolean isEmpty() {
// return link.isEmpty();
// }
// }
| import android.content.Context;
import android.os.Environment;
import java.io.File;
import java.io.FileFilter;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import gov.sequarius.toys.gallery.R;
import gov.sequarius.toys.gallery.module.main.MainView;
import gov.sequarius.toys.gallery.task.ScanHandler;
import gov.sequarius.toys.gallery.task.ScanImageFileTask;
import gov.sequarius.toys.gallery.utils.FileFilterBySuffix;
import gov.sequarius.toys.gallery.utils.SimpleQueue;
| executorService.execute(new ScanImageFileTask(externalCacheDir, executorService,
mDataSet, new ScanHandler() {
@Override
//simple call back when traversal completed
public void onFinish(long finishTime) {
mView.notifyDataSetChanged();
mView.makeCommonSnake(mContext.getString(R.string.message_format_load_result,
mDataSet.size(), finishTime - getStartTime()));
mView.setProgressBarVisible(false);
//shutdown thread pool
executorService.shutdown();
}
}));
}
/**
* get image files by single thread
*/
public void getExternalImageBySingleThread() {
mView.setProgressBarVisible(true);
new singleThreadScanTask().start();
}
private class singleThreadScanTask extends Thread {
@Override
public void run() {
File externalCacheDir = Environment.getExternalStorageDirectory();
mDataSet.clear();
long startTime = System.currentTimeMillis();
FileFilter filter = new FileFilterBySuffix(ScanHandler.SUFFIX_JPG);
| // Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/module/main/MainView.java
// public interface MainView {
// void notifyDataSetChanged();
//
// void initView();
//
// void makeCommonSnake(String message);
//
// void setProgressBarVisible(boolean visible);
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/task/ScanHandler.java
// public abstract class ScanHandler {
// public static final String SUFFIX_JPG = "jpg";
// private int taskCount;
//
// private FileFilter fileFilter;
//
// private long mStartTime=Long.MIN_VALUE;
//
// public long getStartTime() {
// return mStartTime;
// }
//
// public ScanHandler() {
// fileFilter=new FileFilterBySuffix(SUFFIX_JPG);
// mStartTime=System.currentTimeMillis();
// }
//
// public FileFilter getFileFilter() {
// return fileFilter;
// }
//
// public abstract void onFinish(long finishTime);
//
// public synchronized void addTaskCount() {
// taskCount += 1;
// }
//
// public synchronized int devideTaskCount() {
// taskCount -= 1;
// return taskCount;
// }
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/task/ScanImageFileTask.java
// public class ScanImageFileTask implements Runnable {
//
// private File mDirectory;
// private ExecutorService mExecutor;
// private List<File> mResultFileSet;
// private ScanHandler mHandler;
//
// public ScanImageFileTask(File directory, ExecutorService executor, List<File> resultFileSet, ScanHandler handler) {
// this.mHandler = handler;
// handler.addTaskCount();
// this.mDirectory = directory;
// this.mExecutor = executor;
// this.mResultFileSet = resultFileSet;
// }
//
// @Override
// public void run() {
// File[] files = mDirectory.listFiles();
// if (files != null) {
// for (File file : files) {
// if (file.isDirectory()) {
// mExecutor.execute(new ScanImageFileTask(file, mExecutor, mResultFileSet, mHandler));
// } else {
// if (mHandler.getFileFilter().accept(file)) {
// mResultFileSet.add(file);
// }
// }
// }
// }
// //traversal finish
// if (mHandler.devideTaskCount() == 0) {
// mHandler.onFinish(System.currentTimeMillis());
// }
// }
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/utils/FileFilterBySuffix.java
// public class FileFilterBySuffix implements FileFilter {
//
// private String suffix;
//
// public FileFilterBySuffix(String suffix) {
// super();
// this.suffix = suffix;
// }
//
// @Override
// public boolean accept(File pathname) {
//
// return pathname.getName().endsWith(suffix);
// }
// }
//
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/utils/SimpleQueue.java
// public class SimpleQueue<E> {
// private LinkedList<E> link;
//
//
// public SimpleQueue() {
// link = new LinkedList<E>();
// }
//
// public void add(E obj) {
// link.addFirst(obj);
// }
//
//
// public E peek() {
// return link.removeLast();
// }
//
//
// public boolean isEmpty() {
// return link.isEmpty();
// }
// }
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/presenter/MainPresenter.java
import android.content.Context;
import android.os.Environment;
import java.io.File;
import java.io.FileFilter;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import gov.sequarius.toys.gallery.R;
import gov.sequarius.toys.gallery.module.main.MainView;
import gov.sequarius.toys.gallery.task.ScanHandler;
import gov.sequarius.toys.gallery.task.ScanImageFileTask;
import gov.sequarius.toys.gallery.utils.FileFilterBySuffix;
import gov.sequarius.toys.gallery.utils.SimpleQueue;
executorService.execute(new ScanImageFileTask(externalCacheDir, executorService,
mDataSet, new ScanHandler() {
@Override
//simple call back when traversal completed
public void onFinish(long finishTime) {
mView.notifyDataSetChanged();
mView.makeCommonSnake(mContext.getString(R.string.message_format_load_result,
mDataSet.size(), finishTime - getStartTime()));
mView.setProgressBarVisible(false);
//shutdown thread pool
executorService.shutdown();
}
}));
}
/**
* get image files by single thread
*/
public void getExternalImageBySingleThread() {
mView.setProgressBarVisible(true);
new singleThreadScanTask().start();
}
private class singleThreadScanTask extends Thread {
@Override
public void run() {
File externalCacheDir = Environment.getExternalStorageDirectory();
mDataSet.clear();
long startTime = System.currentTimeMillis();
FileFilter filter = new FileFilterBySuffix(ScanHandler.SUFFIX_JPG);
| SimpleQueue<File> queue = new SimpleQueue<>();
|
sequarius/SequariusToys | MicroBlog/src/main/java/com/sequarius/microblog/services/impl/PostServiceImpl.java | // Path: MicroBlog/src/main/java/com/sequarius/microblog/daos/PostDao.java
// public interface PostDao {
// void savePost(Post post);
// List<Post> getPostList();
//
// List<Post> getPostsByUsername(String username);
// }
//
// Path: MicroBlog/src/main/java/com/sequarius/microblog/entities/Post.java
// @Entity
// @Table(name="post")
// public class Post {
// @Id
// @GenericGenerator(name="generator",strategy="increment")
// @GeneratedValue(generator="generator")
// private long id;
//
// @Column(length = 140)
// @Length(max = 140,message = "{comment.content.length.illegal}")
// @NotEmpty(message = "{comment.content.empty.illegal}")
// private String content;
//
// @OneToOne
// private User user;
//
// @Column(name="post_time")
// private long postTime;
//
// @OneToMany(fetch = FetchType.EAGER)
// private List<Comment> comments=new ArrayList<Comment>();
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getContent() {
// return content;
// }
//
// public void setContent(String content) {
// this.content = content;
// }
//
// public User getUser() {
// return user;
// }
//
// public void setUser(User user) {
// this.user = user;
// }
//
// public long getPostTime() {
// return postTime;
// }
//
// public void setPostTime(long postTime) {
// this.postTime = postTime;
// }
//
// public List<Comment> getComments() {
// return comments;
// }
//
// public void setComments(List<Comment> comments) {
// this.comments = comments;
// }
//
// @Override
// public String toString() {
// return "Post{" +
// "id=" + id +
// ", content='" + content + '\'' +
// ", user=" + user +
// ", postTime=" + postTime +
// ", comments=" + comments +
// '}';
// }
// }
//
// Path: MicroBlog/src/main/java/com/sequarius/microblog/services/PostService.java
// public interface PostService {
//
// void publishPost(Post post);
// List<Post> getPosts();
// List<Post> findPostByUserName(String username);
// }
| import com.sequarius.microblog.daos.PostDao;
import com.sequarius.microblog.entities.Post;
import com.sequarius.microblog.services.PostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List; | package com.sequarius.microblog.services.impl;
/**
* Created by Sequarius on 2015/6/7.
*/
@Service("postService")
public class PostServiceImpl extends BaseService implements PostService {
@Autowired | // Path: MicroBlog/src/main/java/com/sequarius/microblog/daos/PostDao.java
// public interface PostDao {
// void savePost(Post post);
// List<Post> getPostList();
//
// List<Post> getPostsByUsername(String username);
// }
//
// Path: MicroBlog/src/main/java/com/sequarius/microblog/entities/Post.java
// @Entity
// @Table(name="post")
// public class Post {
// @Id
// @GenericGenerator(name="generator",strategy="increment")
// @GeneratedValue(generator="generator")
// private long id;
//
// @Column(length = 140)
// @Length(max = 140,message = "{comment.content.length.illegal}")
// @NotEmpty(message = "{comment.content.empty.illegal}")
// private String content;
//
// @OneToOne
// private User user;
//
// @Column(name="post_time")
// private long postTime;
//
// @OneToMany(fetch = FetchType.EAGER)
// private List<Comment> comments=new ArrayList<Comment>();
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getContent() {
// return content;
// }
//
// public void setContent(String content) {
// this.content = content;
// }
//
// public User getUser() {
// return user;
// }
//
// public void setUser(User user) {
// this.user = user;
// }
//
// public long getPostTime() {
// return postTime;
// }
//
// public void setPostTime(long postTime) {
// this.postTime = postTime;
// }
//
// public List<Comment> getComments() {
// return comments;
// }
//
// public void setComments(List<Comment> comments) {
// this.comments = comments;
// }
//
// @Override
// public String toString() {
// return "Post{" +
// "id=" + id +
// ", content='" + content + '\'' +
// ", user=" + user +
// ", postTime=" + postTime +
// ", comments=" + comments +
// '}';
// }
// }
//
// Path: MicroBlog/src/main/java/com/sequarius/microblog/services/PostService.java
// public interface PostService {
//
// void publishPost(Post post);
// List<Post> getPosts();
// List<Post> findPostByUserName(String username);
// }
// Path: MicroBlog/src/main/java/com/sequarius/microblog/services/impl/PostServiceImpl.java
import com.sequarius.microblog.daos.PostDao;
import com.sequarius.microblog.entities.Post;
import com.sequarius.microblog.services.PostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
package com.sequarius.microblog.services.impl;
/**
* Created by Sequarius on 2015/6/7.
*/
@Service("postService")
public class PostServiceImpl extends BaseService implements PostService {
@Autowired | PostDao postDao; |
sequarius/SequariusToys | MicroBlog/src/main/java/com/sequarius/microblog/services/impl/PostServiceImpl.java | // Path: MicroBlog/src/main/java/com/sequarius/microblog/daos/PostDao.java
// public interface PostDao {
// void savePost(Post post);
// List<Post> getPostList();
//
// List<Post> getPostsByUsername(String username);
// }
//
// Path: MicroBlog/src/main/java/com/sequarius/microblog/entities/Post.java
// @Entity
// @Table(name="post")
// public class Post {
// @Id
// @GenericGenerator(name="generator",strategy="increment")
// @GeneratedValue(generator="generator")
// private long id;
//
// @Column(length = 140)
// @Length(max = 140,message = "{comment.content.length.illegal}")
// @NotEmpty(message = "{comment.content.empty.illegal}")
// private String content;
//
// @OneToOne
// private User user;
//
// @Column(name="post_time")
// private long postTime;
//
// @OneToMany(fetch = FetchType.EAGER)
// private List<Comment> comments=new ArrayList<Comment>();
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getContent() {
// return content;
// }
//
// public void setContent(String content) {
// this.content = content;
// }
//
// public User getUser() {
// return user;
// }
//
// public void setUser(User user) {
// this.user = user;
// }
//
// public long getPostTime() {
// return postTime;
// }
//
// public void setPostTime(long postTime) {
// this.postTime = postTime;
// }
//
// public List<Comment> getComments() {
// return comments;
// }
//
// public void setComments(List<Comment> comments) {
// this.comments = comments;
// }
//
// @Override
// public String toString() {
// return "Post{" +
// "id=" + id +
// ", content='" + content + '\'' +
// ", user=" + user +
// ", postTime=" + postTime +
// ", comments=" + comments +
// '}';
// }
// }
//
// Path: MicroBlog/src/main/java/com/sequarius/microblog/services/PostService.java
// public interface PostService {
//
// void publishPost(Post post);
// List<Post> getPosts();
// List<Post> findPostByUserName(String username);
// }
| import com.sequarius.microblog.daos.PostDao;
import com.sequarius.microblog.entities.Post;
import com.sequarius.microblog.services.PostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List; | package com.sequarius.microblog.services.impl;
/**
* Created by Sequarius on 2015/6/7.
*/
@Service("postService")
public class PostServiceImpl extends BaseService implements PostService {
@Autowired
PostDao postDao;
@Override | // Path: MicroBlog/src/main/java/com/sequarius/microblog/daos/PostDao.java
// public interface PostDao {
// void savePost(Post post);
// List<Post> getPostList();
//
// List<Post> getPostsByUsername(String username);
// }
//
// Path: MicroBlog/src/main/java/com/sequarius/microblog/entities/Post.java
// @Entity
// @Table(name="post")
// public class Post {
// @Id
// @GenericGenerator(name="generator",strategy="increment")
// @GeneratedValue(generator="generator")
// private long id;
//
// @Column(length = 140)
// @Length(max = 140,message = "{comment.content.length.illegal}")
// @NotEmpty(message = "{comment.content.empty.illegal}")
// private String content;
//
// @OneToOne
// private User user;
//
// @Column(name="post_time")
// private long postTime;
//
// @OneToMany(fetch = FetchType.EAGER)
// private List<Comment> comments=new ArrayList<Comment>();
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getContent() {
// return content;
// }
//
// public void setContent(String content) {
// this.content = content;
// }
//
// public User getUser() {
// return user;
// }
//
// public void setUser(User user) {
// this.user = user;
// }
//
// public long getPostTime() {
// return postTime;
// }
//
// public void setPostTime(long postTime) {
// this.postTime = postTime;
// }
//
// public List<Comment> getComments() {
// return comments;
// }
//
// public void setComments(List<Comment> comments) {
// this.comments = comments;
// }
//
// @Override
// public String toString() {
// return "Post{" +
// "id=" + id +
// ", content='" + content + '\'' +
// ", user=" + user +
// ", postTime=" + postTime +
// ", comments=" + comments +
// '}';
// }
// }
//
// Path: MicroBlog/src/main/java/com/sequarius/microblog/services/PostService.java
// public interface PostService {
//
// void publishPost(Post post);
// List<Post> getPosts();
// List<Post> findPostByUserName(String username);
// }
// Path: MicroBlog/src/main/java/com/sequarius/microblog/services/impl/PostServiceImpl.java
import com.sequarius.microblog.daos.PostDao;
import com.sequarius.microblog.entities.Post;
import com.sequarius.microblog.services.PostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
package com.sequarius.microblog.services.impl;
/**
* Created by Sequarius on 2015/6/7.
*/
@Service("postService")
public class PostServiceImpl extends BaseService implements PostService {
@Autowired
PostDao postDao;
@Override | public void publishPost(Post post) { |
sequarius/SequariusToys | MicroBlog/src/main/java/com/sequarius/microblog/daos/impl/PostDaoImpl.java | // Path: MicroBlog/src/main/java/com/sequarius/microblog/daos/PostDao.java
// public interface PostDao {
// void savePost(Post post);
// List<Post> getPostList();
//
// List<Post> getPostsByUsername(String username);
// }
//
// Path: MicroBlog/src/main/java/com/sequarius/microblog/entities/Post.java
// @Entity
// @Table(name="post")
// public class Post {
// @Id
// @GenericGenerator(name="generator",strategy="increment")
// @GeneratedValue(generator="generator")
// private long id;
//
// @Column(length = 140)
// @Length(max = 140,message = "{comment.content.length.illegal}")
// @NotEmpty(message = "{comment.content.empty.illegal}")
// private String content;
//
// @OneToOne
// private User user;
//
// @Column(name="post_time")
// private long postTime;
//
// @OneToMany(fetch = FetchType.EAGER)
// private List<Comment> comments=new ArrayList<Comment>();
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getContent() {
// return content;
// }
//
// public void setContent(String content) {
// this.content = content;
// }
//
// public User getUser() {
// return user;
// }
//
// public void setUser(User user) {
// this.user = user;
// }
//
// public long getPostTime() {
// return postTime;
// }
//
// public void setPostTime(long postTime) {
// this.postTime = postTime;
// }
//
// public List<Comment> getComments() {
// return comments;
// }
//
// public void setComments(List<Comment> comments) {
// this.comments = comments;
// }
//
// @Override
// public String toString() {
// return "Post{" +
// "id=" + id +
// ", content='" + content + '\'' +
// ", user=" + user +
// ", postTime=" + postTime +
// ", comments=" + comments +
// '}';
// }
// }
| import com.sequarius.microblog.daos.PostDao;
import com.sequarius.microblog.entities.Post;
import org.hibernate.Query;
import org.springframework.stereotype.Repository;
import java.util.List; | package com.sequarius.microblog.daos.impl;
/**
* Created by Sequarius on 2015/6/7.
*/
@Repository("postDao")
public class PostDaoImpl extends BaseDao implements PostDao {
@Override | // Path: MicroBlog/src/main/java/com/sequarius/microblog/daos/PostDao.java
// public interface PostDao {
// void savePost(Post post);
// List<Post> getPostList();
//
// List<Post> getPostsByUsername(String username);
// }
//
// Path: MicroBlog/src/main/java/com/sequarius/microblog/entities/Post.java
// @Entity
// @Table(name="post")
// public class Post {
// @Id
// @GenericGenerator(name="generator",strategy="increment")
// @GeneratedValue(generator="generator")
// private long id;
//
// @Column(length = 140)
// @Length(max = 140,message = "{comment.content.length.illegal}")
// @NotEmpty(message = "{comment.content.empty.illegal}")
// private String content;
//
// @OneToOne
// private User user;
//
// @Column(name="post_time")
// private long postTime;
//
// @OneToMany(fetch = FetchType.EAGER)
// private List<Comment> comments=new ArrayList<Comment>();
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getContent() {
// return content;
// }
//
// public void setContent(String content) {
// this.content = content;
// }
//
// public User getUser() {
// return user;
// }
//
// public void setUser(User user) {
// this.user = user;
// }
//
// public long getPostTime() {
// return postTime;
// }
//
// public void setPostTime(long postTime) {
// this.postTime = postTime;
// }
//
// public List<Comment> getComments() {
// return comments;
// }
//
// public void setComments(List<Comment> comments) {
// this.comments = comments;
// }
//
// @Override
// public String toString() {
// return "Post{" +
// "id=" + id +
// ", content='" + content + '\'' +
// ", user=" + user +
// ", postTime=" + postTime +
// ", comments=" + comments +
// '}';
// }
// }
// Path: MicroBlog/src/main/java/com/sequarius/microblog/daos/impl/PostDaoImpl.java
import com.sequarius.microblog.daos.PostDao;
import com.sequarius.microblog.entities.Post;
import org.hibernate.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
package com.sequarius.microblog.daos.impl;
/**
* Created by Sequarius on 2015/6/7.
*/
@Repository("postDao")
public class PostDaoImpl extends BaseDao implements PostDao {
@Override | public void savePost(Post post) { |
sequarius/SequariusToys | MicroBlog/src/main/java/com/sequarius/microblog/services/impl/UserServiceImpl.java | // Path: MicroBlog/src/main/java/com/sequarius/microblog/daos/UserDao.java
// public interface UserDao {
//
// void saveUser(User user);
//
// User findUserByMail(String mail);
//
// User findUserByUsername(String username);
// }
//
// Path: MicroBlog/src/main/java/com/sequarius/microblog/entities/User.java
// @Entity
// @Table(name = "user")
// public class User implements Serializable {
// private static final long serialVersionUID = -2602075959996355784L;
//
//
// @Id
// @GenericGenerator(name="generator",strategy="increment")
// @GeneratedValue(generator="generator")
// private long id;
// @Length(min=0,max = 20,message = "{user.username.length.illegal}")
// @Column(length = 20,nullable = false,unique = true)
// private String username;
// @Length(min=6,max = 16,message="{user.password.length.illegal}")
// @Column(length = 16,nullable = false)
// private String password;
// @Column(length = 70)
// private String address;
//
//
// @Email(message = "{user.mail.format.illegal}")
// @NotEmpty(message ="{user.mail.empty.illegal}")
// @Column(length = 128,nullable = false,unique = true)
// private String email;
// @Column(length = 128)
// private String avatar;
// @Column(name = "phone_num",length = 20)
// @Pattern(regexp = "[1][34578]\\d{9}", message = "{user.phone.leagl.error}")
// private String phoneNum;
// @Column(name = "regist_time")
// private long registTime;
// @Column(name = "last_login")
// private long lastLogin;
// @Column(name ="last_login_ip",length = 15)
// private String lastLoginIp;
// @Column(length = 1)
// @Pattern(regexp = "['男''女']", message = "{user.gender.leagl.error}")
// private String gender;
//
// public static long getSerialVersionUID() {
// return serialVersionUID;
// }
//
// public String getAvatar() {
// return avatar;
// }
//
// public void setAvatar(String avatar) {
// this.avatar = avatar;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getAddress() {
// return address;
// }
//
// public void setAddress(String address) {
// this.address = address;
// }
//
// public String getPhoneNum() {
// return phoneNum;
// }
//
// public void setPhoneNum(String phoneNum) {
// this.phoneNum = phoneNum;
// }
//
// public long getRegistTime() {
// return registTime;
// }
//
// public void setRegistTime(long registTime) {
// this.registTime = registTime;
// }
//
// public long getLastLogin() {
// return lastLogin;
// }
//
// public void setLastLogin(long lastLogin) {
// this.lastLogin = lastLogin;
// }
//
// public String getLastLoginIp() {
// return lastLoginIp;
// }
//
// public void setLastLoginIp(String lastLoginIp) {
// this.lastLoginIp = lastLoginIp;
// }
//
// public String getGender() {
// return gender;
// }
//
// public void setGender(String gender) {
// this.gender = gender;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", username='" + username + '\'' +
// ", password='" + password + '\'' +
// ", address='" + address + '\'' +
// ", email='" + email + '\'' +
// ", avatar='" + avatar + '\'' +
// ", phoneNum='" + phoneNum + '\'' +
// ", registTime=" + registTime +
// ", lastLogin=" + lastLogin +
// ", lastLoginIp='" + lastLoginIp + '\'' +
// ", gender='" + gender + '\'' +
// '}';
// }
// }
//
// Path: MicroBlog/src/main/java/com/sequarius/microblog/services/UserService.java
// public interface UserService {
// void saveUser(User user);
//
// boolean isMailExisted(String mail);
//
// boolean isUsernameExisted(String username);
//
// boolean isLegalUser(User user);
//
// User findUserByMail(String email);
//
// User findUserByUsername(String username);
// }
| import com.sequarius.microblog.daos.UserDao;
import com.sequarius.microblog.entities.User;
import com.sequarius.microblog.services.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; | package com.sequarius.microblog.services.impl;
/**
* Created by Sequarius on 2015/5/31.
*/
@Service("userService")
public class UserServiceImpl extends BaseService implements UserService{
@Autowired | // Path: MicroBlog/src/main/java/com/sequarius/microblog/daos/UserDao.java
// public interface UserDao {
//
// void saveUser(User user);
//
// User findUserByMail(String mail);
//
// User findUserByUsername(String username);
// }
//
// Path: MicroBlog/src/main/java/com/sequarius/microblog/entities/User.java
// @Entity
// @Table(name = "user")
// public class User implements Serializable {
// private static final long serialVersionUID = -2602075959996355784L;
//
//
// @Id
// @GenericGenerator(name="generator",strategy="increment")
// @GeneratedValue(generator="generator")
// private long id;
// @Length(min=0,max = 20,message = "{user.username.length.illegal}")
// @Column(length = 20,nullable = false,unique = true)
// private String username;
// @Length(min=6,max = 16,message="{user.password.length.illegal}")
// @Column(length = 16,nullable = false)
// private String password;
// @Column(length = 70)
// private String address;
//
//
// @Email(message = "{user.mail.format.illegal}")
// @NotEmpty(message ="{user.mail.empty.illegal}")
// @Column(length = 128,nullable = false,unique = true)
// private String email;
// @Column(length = 128)
// private String avatar;
// @Column(name = "phone_num",length = 20)
// @Pattern(regexp = "[1][34578]\\d{9}", message = "{user.phone.leagl.error}")
// private String phoneNum;
// @Column(name = "regist_time")
// private long registTime;
// @Column(name = "last_login")
// private long lastLogin;
// @Column(name ="last_login_ip",length = 15)
// private String lastLoginIp;
// @Column(length = 1)
// @Pattern(regexp = "['男''女']", message = "{user.gender.leagl.error}")
// private String gender;
//
// public static long getSerialVersionUID() {
// return serialVersionUID;
// }
//
// public String getAvatar() {
// return avatar;
// }
//
// public void setAvatar(String avatar) {
// this.avatar = avatar;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getAddress() {
// return address;
// }
//
// public void setAddress(String address) {
// this.address = address;
// }
//
// public String getPhoneNum() {
// return phoneNum;
// }
//
// public void setPhoneNum(String phoneNum) {
// this.phoneNum = phoneNum;
// }
//
// public long getRegistTime() {
// return registTime;
// }
//
// public void setRegistTime(long registTime) {
// this.registTime = registTime;
// }
//
// public long getLastLogin() {
// return lastLogin;
// }
//
// public void setLastLogin(long lastLogin) {
// this.lastLogin = lastLogin;
// }
//
// public String getLastLoginIp() {
// return lastLoginIp;
// }
//
// public void setLastLoginIp(String lastLoginIp) {
// this.lastLoginIp = lastLoginIp;
// }
//
// public String getGender() {
// return gender;
// }
//
// public void setGender(String gender) {
// this.gender = gender;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", username='" + username + '\'' +
// ", password='" + password + '\'' +
// ", address='" + address + '\'' +
// ", email='" + email + '\'' +
// ", avatar='" + avatar + '\'' +
// ", phoneNum='" + phoneNum + '\'' +
// ", registTime=" + registTime +
// ", lastLogin=" + lastLogin +
// ", lastLoginIp='" + lastLoginIp + '\'' +
// ", gender='" + gender + '\'' +
// '}';
// }
// }
//
// Path: MicroBlog/src/main/java/com/sequarius/microblog/services/UserService.java
// public interface UserService {
// void saveUser(User user);
//
// boolean isMailExisted(String mail);
//
// boolean isUsernameExisted(String username);
//
// boolean isLegalUser(User user);
//
// User findUserByMail(String email);
//
// User findUserByUsername(String username);
// }
// Path: MicroBlog/src/main/java/com/sequarius/microblog/services/impl/UserServiceImpl.java
import com.sequarius.microblog.daos.UserDao;
import com.sequarius.microblog.entities.User;
import com.sequarius.microblog.services.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
package com.sequarius.microblog.services.impl;
/**
* Created by Sequarius on 2015/5/31.
*/
@Service("userService")
public class UserServiceImpl extends BaseService implements UserService{
@Autowired | private UserDao userDao; |
sequarius/SequariusToys | MicroBlog/src/main/java/com/sequarius/microblog/services/impl/UserServiceImpl.java | // Path: MicroBlog/src/main/java/com/sequarius/microblog/daos/UserDao.java
// public interface UserDao {
//
// void saveUser(User user);
//
// User findUserByMail(String mail);
//
// User findUserByUsername(String username);
// }
//
// Path: MicroBlog/src/main/java/com/sequarius/microblog/entities/User.java
// @Entity
// @Table(name = "user")
// public class User implements Serializable {
// private static final long serialVersionUID = -2602075959996355784L;
//
//
// @Id
// @GenericGenerator(name="generator",strategy="increment")
// @GeneratedValue(generator="generator")
// private long id;
// @Length(min=0,max = 20,message = "{user.username.length.illegal}")
// @Column(length = 20,nullable = false,unique = true)
// private String username;
// @Length(min=6,max = 16,message="{user.password.length.illegal}")
// @Column(length = 16,nullable = false)
// private String password;
// @Column(length = 70)
// private String address;
//
//
// @Email(message = "{user.mail.format.illegal}")
// @NotEmpty(message ="{user.mail.empty.illegal}")
// @Column(length = 128,nullable = false,unique = true)
// private String email;
// @Column(length = 128)
// private String avatar;
// @Column(name = "phone_num",length = 20)
// @Pattern(regexp = "[1][34578]\\d{9}", message = "{user.phone.leagl.error}")
// private String phoneNum;
// @Column(name = "regist_time")
// private long registTime;
// @Column(name = "last_login")
// private long lastLogin;
// @Column(name ="last_login_ip",length = 15)
// private String lastLoginIp;
// @Column(length = 1)
// @Pattern(regexp = "['男''女']", message = "{user.gender.leagl.error}")
// private String gender;
//
// public static long getSerialVersionUID() {
// return serialVersionUID;
// }
//
// public String getAvatar() {
// return avatar;
// }
//
// public void setAvatar(String avatar) {
// this.avatar = avatar;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getAddress() {
// return address;
// }
//
// public void setAddress(String address) {
// this.address = address;
// }
//
// public String getPhoneNum() {
// return phoneNum;
// }
//
// public void setPhoneNum(String phoneNum) {
// this.phoneNum = phoneNum;
// }
//
// public long getRegistTime() {
// return registTime;
// }
//
// public void setRegistTime(long registTime) {
// this.registTime = registTime;
// }
//
// public long getLastLogin() {
// return lastLogin;
// }
//
// public void setLastLogin(long lastLogin) {
// this.lastLogin = lastLogin;
// }
//
// public String getLastLoginIp() {
// return lastLoginIp;
// }
//
// public void setLastLoginIp(String lastLoginIp) {
// this.lastLoginIp = lastLoginIp;
// }
//
// public String getGender() {
// return gender;
// }
//
// public void setGender(String gender) {
// this.gender = gender;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", username='" + username + '\'' +
// ", password='" + password + '\'' +
// ", address='" + address + '\'' +
// ", email='" + email + '\'' +
// ", avatar='" + avatar + '\'' +
// ", phoneNum='" + phoneNum + '\'' +
// ", registTime=" + registTime +
// ", lastLogin=" + lastLogin +
// ", lastLoginIp='" + lastLoginIp + '\'' +
// ", gender='" + gender + '\'' +
// '}';
// }
// }
//
// Path: MicroBlog/src/main/java/com/sequarius/microblog/services/UserService.java
// public interface UserService {
// void saveUser(User user);
//
// boolean isMailExisted(String mail);
//
// boolean isUsernameExisted(String username);
//
// boolean isLegalUser(User user);
//
// User findUserByMail(String email);
//
// User findUserByUsername(String username);
// }
| import com.sequarius.microblog.daos.UserDao;
import com.sequarius.microblog.entities.User;
import com.sequarius.microblog.services.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; | package com.sequarius.microblog.services.impl;
/**
* Created by Sequarius on 2015/5/31.
*/
@Service("userService")
public class UserServiceImpl extends BaseService implements UserService{
@Autowired
private UserDao userDao;
@Override | // Path: MicroBlog/src/main/java/com/sequarius/microblog/daos/UserDao.java
// public interface UserDao {
//
// void saveUser(User user);
//
// User findUserByMail(String mail);
//
// User findUserByUsername(String username);
// }
//
// Path: MicroBlog/src/main/java/com/sequarius/microblog/entities/User.java
// @Entity
// @Table(name = "user")
// public class User implements Serializable {
// private static final long serialVersionUID = -2602075959996355784L;
//
//
// @Id
// @GenericGenerator(name="generator",strategy="increment")
// @GeneratedValue(generator="generator")
// private long id;
// @Length(min=0,max = 20,message = "{user.username.length.illegal}")
// @Column(length = 20,nullable = false,unique = true)
// private String username;
// @Length(min=6,max = 16,message="{user.password.length.illegal}")
// @Column(length = 16,nullable = false)
// private String password;
// @Column(length = 70)
// private String address;
//
//
// @Email(message = "{user.mail.format.illegal}")
// @NotEmpty(message ="{user.mail.empty.illegal}")
// @Column(length = 128,nullable = false,unique = true)
// private String email;
// @Column(length = 128)
// private String avatar;
// @Column(name = "phone_num",length = 20)
// @Pattern(regexp = "[1][34578]\\d{9}", message = "{user.phone.leagl.error}")
// private String phoneNum;
// @Column(name = "regist_time")
// private long registTime;
// @Column(name = "last_login")
// private long lastLogin;
// @Column(name ="last_login_ip",length = 15)
// private String lastLoginIp;
// @Column(length = 1)
// @Pattern(regexp = "['男''女']", message = "{user.gender.leagl.error}")
// private String gender;
//
// public static long getSerialVersionUID() {
// return serialVersionUID;
// }
//
// public String getAvatar() {
// return avatar;
// }
//
// public void setAvatar(String avatar) {
// this.avatar = avatar;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getAddress() {
// return address;
// }
//
// public void setAddress(String address) {
// this.address = address;
// }
//
// public String getPhoneNum() {
// return phoneNum;
// }
//
// public void setPhoneNum(String phoneNum) {
// this.phoneNum = phoneNum;
// }
//
// public long getRegistTime() {
// return registTime;
// }
//
// public void setRegistTime(long registTime) {
// this.registTime = registTime;
// }
//
// public long getLastLogin() {
// return lastLogin;
// }
//
// public void setLastLogin(long lastLogin) {
// this.lastLogin = lastLogin;
// }
//
// public String getLastLoginIp() {
// return lastLoginIp;
// }
//
// public void setLastLoginIp(String lastLoginIp) {
// this.lastLoginIp = lastLoginIp;
// }
//
// public String getGender() {
// return gender;
// }
//
// public void setGender(String gender) {
// this.gender = gender;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", username='" + username + '\'' +
// ", password='" + password + '\'' +
// ", address='" + address + '\'' +
// ", email='" + email + '\'' +
// ", avatar='" + avatar + '\'' +
// ", phoneNum='" + phoneNum + '\'' +
// ", registTime=" + registTime +
// ", lastLogin=" + lastLogin +
// ", lastLoginIp='" + lastLoginIp + '\'' +
// ", gender='" + gender + '\'' +
// '}';
// }
// }
//
// Path: MicroBlog/src/main/java/com/sequarius/microblog/services/UserService.java
// public interface UserService {
// void saveUser(User user);
//
// boolean isMailExisted(String mail);
//
// boolean isUsernameExisted(String username);
//
// boolean isLegalUser(User user);
//
// User findUserByMail(String email);
//
// User findUserByUsername(String username);
// }
// Path: MicroBlog/src/main/java/com/sequarius/microblog/services/impl/UserServiceImpl.java
import com.sequarius.microblog.daos.UserDao;
import com.sequarius.microblog.entities.User;
import com.sequarius.microblog.services.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
package com.sequarius.microblog.services.impl;
/**
* Created by Sequarius on 2015/5/31.
*/
@Service("userService")
public class UserServiceImpl extends BaseService implements UserService{
@Autowired
private UserDao userDao;
@Override | public void saveUser(User user){ |
sequarius/SequariusToys | MicroBlog/src/main/java/com/sequarius/microblog/utilities/CommonValidator.java | // Path: MicroBlog/src/main/java/com/sequarius/microblog/entities/User.java
// @Entity
// @Table(name = "user")
// public class User implements Serializable {
// private static final long serialVersionUID = -2602075959996355784L;
//
//
// @Id
// @GenericGenerator(name="generator",strategy="increment")
// @GeneratedValue(generator="generator")
// private long id;
// @Length(min=0,max = 20,message = "{user.username.length.illegal}")
// @Column(length = 20,nullable = false,unique = true)
// private String username;
// @Length(min=6,max = 16,message="{user.password.length.illegal}")
// @Column(length = 16,nullable = false)
// private String password;
// @Column(length = 70)
// private String address;
//
//
// @Email(message = "{user.mail.format.illegal}")
// @NotEmpty(message ="{user.mail.empty.illegal}")
// @Column(length = 128,nullable = false,unique = true)
// private String email;
// @Column(length = 128)
// private String avatar;
// @Column(name = "phone_num",length = 20)
// @Pattern(regexp = "[1][34578]\\d{9}", message = "{user.phone.leagl.error}")
// private String phoneNum;
// @Column(name = "regist_time")
// private long registTime;
// @Column(name = "last_login")
// private long lastLogin;
// @Column(name ="last_login_ip",length = 15)
// private String lastLoginIp;
// @Column(length = 1)
// @Pattern(regexp = "['男''女']", message = "{user.gender.leagl.error}")
// private String gender;
//
// public static long getSerialVersionUID() {
// return serialVersionUID;
// }
//
// public String getAvatar() {
// return avatar;
// }
//
// public void setAvatar(String avatar) {
// this.avatar = avatar;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getAddress() {
// return address;
// }
//
// public void setAddress(String address) {
// this.address = address;
// }
//
// public String getPhoneNum() {
// return phoneNum;
// }
//
// public void setPhoneNum(String phoneNum) {
// this.phoneNum = phoneNum;
// }
//
// public long getRegistTime() {
// return registTime;
// }
//
// public void setRegistTime(long registTime) {
// this.registTime = registTime;
// }
//
// public long getLastLogin() {
// return lastLogin;
// }
//
// public void setLastLogin(long lastLogin) {
// this.lastLogin = lastLogin;
// }
//
// public String getLastLoginIp() {
// return lastLoginIp;
// }
//
// public void setLastLoginIp(String lastLoginIp) {
// this.lastLoginIp = lastLoginIp;
// }
//
// public String getGender() {
// return gender;
// }
//
// public void setGender(String gender) {
// this.gender = gender;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", username='" + username + '\'' +
// ", password='" + password + '\'' +
// ", address='" + address + '\'' +
// ", email='" + email + '\'' +
// ", avatar='" + avatar + '\'' +
// ", phoneNum='" + phoneNum + '\'' +
// ", registTime=" + registTime +
// ", lastLogin=" + lastLogin +
// ", lastLoginIp='" + lastLoginIp + '\'' +
// ", gender='" + gender + '\'' +
// '}';
// }
// }
| import com.sequarius.microblog.entities.User;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator; | package com.sequarius.microblog.utilities;
/**
* Created by Sequarius on 2015/6/1.
*/
public class CommonValidator implements Validator {
@Override
public boolean supports(Class<?> aClass) { | // Path: MicroBlog/src/main/java/com/sequarius/microblog/entities/User.java
// @Entity
// @Table(name = "user")
// public class User implements Serializable {
// private static final long serialVersionUID = -2602075959996355784L;
//
//
// @Id
// @GenericGenerator(name="generator",strategy="increment")
// @GeneratedValue(generator="generator")
// private long id;
// @Length(min=0,max = 20,message = "{user.username.length.illegal}")
// @Column(length = 20,nullable = false,unique = true)
// private String username;
// @Length(min=6,max = 16,message="{user.password.length.illegal}")
// @Column(length = 16,nullable = false)
// private String password;
// @Column(length = 70)
// private String address;
//
//
// @Email(message = "{user.mail.format.illegal}")
// @NotEmpty(message ="{user.mail.empty.illegal}")
// @Column(length = 128,nullable = false,unique = true)
// private String email;
// @Column(length = 128)
// private String avatar;
// @Column(name = "phone_num",length = 20)
// @Pattern(regexp = "[1][34578]\\d{9}", message = "{user.phone.leagl.error}")
// private String phoneNum;
// @Column(name = "regist_time")
// private long registTime;
// @Column(name = "last_login")
// private long lastLogin;
// @Column(name ="last_login_ip",length = 15)
// private String lastLoginIp;
// @Column(length = 1)
// @Pattern(regexp = "['男''女']", message = "{user.gender.leagl.error}")
// private String gender;
//
// public static long getSerialVersionUID() {
// return serialVersionUID;
// }
//
// public String getAvatar() {
// return avatar;
// }
//
// public void setAvatar(String avatar) {
// this.avatar = avatar;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getAddress() {
// return address;
// }
//
// public void setAddress(String address) {
// this.address = address;
// }
//
// public String getPhoneNum() {
// return phoneNum;
// }
//
// public void setPhoneNum(String phoneNum) {
// this.phoneNum = phoneNum;
// }
//
// public long getRegistTime() {
// return registTime;
// }
//
// public void setRegistTime(long registTime) {
// this.registTime = registTime;
// }
//
// public long getLastLogin() {
// return lastLogin;
// }
//
// public void setLastLogin(long lastLogin) {
// this.lastLogin = lastLogin;
// }
//
// public String getLastLoginIp() {
// return lastLoginIp;
// }
//
// public void setLastLoginIp(String lastLoginIp) {
// this.lastLoginIp = lastLoginIp;
// }
//
// public String getGender() {
// return gender;
// }
//
// public void setGender(String gender) {
// this.gender = gender;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", username='" + username + '\'' +
// ", password='" + password + '\'' +
// ", address='" + address + '\'' +
// ", email='" + email + '\'' +
// ", avatar='" + avatar + '\'' +
// ", phoneNum='" + phoneNum + '\'' +
// ", registTime=" + registTime +
// ", lastLogin=" + lastLogin +
// ", lastLoginIp='" + lastLoginIp + '\'' +
// ", gender='" + gender + '\'' +
// '}';
// }
// }
// Path: MicroBlog/src/main/java/com/sequarius/microblog/utilities/CommonValidator.java
import com.sequarius.microblog.entities.User;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;
package com.sequarius.microblog.utilities;
/**
* Created by Sequarius on 2015/6/1.
*/
public class CommonValidator implements Validator {
@Override
public boolean supports(Class<?> aClass) { | return User.class.equals(aClass); |
sequarius/SequariusToys | GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/task/ScanHandler.java | // Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/utils/FileFilterBySuffix.java
// public class FileFilterBySuffix implements FileFilter {
//
// private String suffix;
//
// public FileFilterBySuffix(String suffix) {
// super();
// this.suffix = suffix;
// }
//
// @Override
// public boolean accept(File pathname) {
//
// return pathname.getName().endsWith(suffix);
// }
// }
| import java.io.FileFilter;
import gov.sequarius.toys.gallery.utils.FileFilterBySuffix;
| package gov.sequarius.toys.gallery.task;
/**
* A handler for ScanImageFileTask
* Created by Sequarius on 2016/5/10.
*/
public abstract class ScanHandler {
public static final String SUFFIX_JPG = "jpg";
private int taskCount;
private FileFilter fileFilter;
private long mStartTime=Long.MIN_VALUE;
public long getStartTime() {
return mStartTime;
}
public ScanHandler() {
| // Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/utils/FileFilterBySuffix.java
// public class FileFilterBySuffix implements FileFilter {
//
// private String suffix;
//
// public FileFilterBySuffix(String suffix) {
// super();
// this.suffix = suffix;
// }
//
// @Override
// public boolean accept(File pathname) {
//
// return pathname.getName().endsWith(suffix);
// }
// }
// Path: GalleryToy/app/src/main/java/gov/sequarius/toys/gallery/task/ScanHandler.java
import java.io.FileFilter;
import gov.sequarius.toys.gallery.utils.FileFilterBySuffix;
package gov.sequarius.toys.gallery.task;
/**
* A handler for ScanImageFileTask
* Created by Sequarius on 2016/5/10.
*/
public abstract class ScanHandler {
public static final String SUFFIX_JPG = "jpg";
private int taskCount;
private FileFilter fileFilter;
private long mStartTime=Long.MIN_VALUE;
public long getStartTime() {
return mStartTime;
}
public ScanHandler() {
| fileFilter=new FileFilterBySuffix(SUFFIX_JPG);
|
sequarius/SequariusToys | LightPlayer/src/com/sequarius/lightplayer/database/PlayListDAO.java | // Path: LightPlayer/src/com/sequarius/lightplayer/object/Song.java
// public class Song {
// private int id;
// private String name;
// public int getId() {
// return id;
// }
// public void setId(int id) {
// this.id = id;
// }
// @Override
// public String toString() {
// // TODO Auto-generated method stub
// return super.toString();
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getUri() {
// return Uri;
// }
// public void setUri(String uri) {
// Uri = uri;
// }
// public Song() {
// }
// public Song(int id, String name, String uri) {
// super();
// this.id = id;
// this.name = name;
// Uri = uri;
// }
// private String Uri;
//
// }
| import java.util.ArrayList;
import java.util.List;
import com.sequarius.lightplayer.object.Song;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
| package com.sequarius.lightplayer.database;
public class PlayListDAO {
private PlayListSQLiteOpenHelper helper;
public PlayListDAO(Context context){
helper =new PlayListSQLiteOpenHelper(context);
}
/**
* Ìí¼ÓÒ»Ìõ¼Ç¼
* @param name ÎļþÃû
* @param uri ÎļþµØÖ·
*/
public void add(String name,String uri){
SQLiteDatabase db=helper.getWritableDatabase();
db.execSQL("insert into playlist (name,uri) values(?,?)",new Object[]{name,uri});
db.close();
}
/**
* ²éѯËùÓиèÇúÁбí
* @return ËùÓÐÔÚ¿â¸èÇú
*/
| // Path: LightPlayer/src/com/sequarius/lightplayer/object/Song.java
// public class Song {
// private int id;
// private String name;
// public int getId() {
// return id;
// }
// public void setId(int id) {
// this.id = id;
// }
// @Override
// public String toString() {
// // TODO Auto-generated method stub
// return super.toString();
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getUri() {
// return Uri;
// }
// public void setUri(String uri) {
// Uri = uri;
// }
// public Song() {
// }
// public Song(int id, String name, String uri) {
// super();
// this.id = id;
// this.name = name;
// Uri = uri;
// }
// private String Uri;
//
// }
// Path: LightPlayer/src/com/sequarius/lightplayer/database/PlayListDAO.java
import java.util.ArrayList;
import java.util.List;
import com.sequarius.lightplayer.object.Song;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
package com.sequarius.lightplayer.database;
public class PlayListDAO {
private PlayListSQLiteOpenHelper helper;
public PlayListDAO(Context context){
helper =new PlayListSQLiteOpenHelper(context);
}
/**
* Ìí¼ÓÒ»Ìõ¼Ç¼
* @param name ÎļþÃû
* @param uri ÎļþµØÖ·
*/
public void add(String name,String uri){
SQLiteDatabase db=helper.getWritableDatabase();
db.execSQL("insert into playlist (name,uri) values(?,?)",new Object[]{name,uri});
db.close();
}
/**
* ²éѯËùÓиèÇúÁбí
* @return ËùÓÐÔÚ¿â¸èÇú
*/
| public List<Song> selectAll(){
|
sequarius/SequariusToys | LightPlayer/src/com/sequarius/lightplayer/fragment/LyricFragment.java | // Path: LightPlayer/src/com/sequarius/lightplayer/object/LrcParse.java
// public class LrcParse {
// private TreeMap<Integer, String> treeMap;
//
// public LrcParse(File file) throws IOException, FileNotFoundException {
// super();
// InputStreamReader isr = new InputStreamReader(new FileInputStream(file), "UTF-8");
// BufferedReader bufferedReader = new BufferedReader(isr);
// List<String> lines=new ArrayList<String>();
// String line;
// while ((line=bufferedReader.readLine())!=null) {
// lines.add(line);
// }
// treeMap=new TreeMap<>();
// for (Iterator<String> iterator = lines.iterator(); iterator.hasNext();) {
// String string = (String) iterator.next();
// parserLine(string);
// }
// bufferedReader.close();
// }
// /**
// * ÓÃÓÚ·µ»Ø½âÎöºóµÄ¸è´Ê
// * @return °´ÕÕʱ¼ä˳Ðò½âÎöºóMap¼¯ºÏ
// */
// public TreeMap<Integer, String> getLrc(){
// return treeMap;
// }
// /**
// * ½«StringÐ͵Ä×Ö·û´®½âÎö³Éʱ¼ä
// * @param timeStr ʱ¼äµÄ×Ö·û´® ¸ñʽΪ[xx:xx.xx]
// * @return ת»»ºóµÄºÁÃëintʱ¼äÖµ
// */
// private int strToInt(String timeStr){
// //È¥³ý[]
// String reg="[\\[|\\]]";
// //½âÎö·ÖÖÖλÖÃ×Ö·û´®
// timeStr=timeStr.replaceAll(reg, "");
// String[] strPre = timeStr.split(":");
// int min = Integer.parseInt(strPre[0]);
// //½âÎöÃëºÍºÁÃëλÖÃ×Ö·û´®
// int sec=0;
// int mill=0;
// if(strPre[1].contains(".")){
// String[] strNext=strPre[1].split("\\.");
// // System.out.println(s[1]);
// sec =Integer.parseInt(strNext[0]);
// mill=Integer.parseInt(strNext[1]);
// }else{
// sec=Integer.parseInt(strPre[1]);
// }
// return min*60*1000+sec*1000+mill*10;
// }
// /**
// * ½âÎöÿһÐеĸè´Ê²¢´æÈëMap
// */
// private void parserLine(String line){
// String reg ="\\[(\\d{1,2}:\\d{1,2}\\.\\d{1,2})\\]|\\[(\\d{1,2}:\\d{1,2})\\]";
// Pattern pattern = Pattern.compile(reg);
// Matcher matcher=pattern.matcher(line);
// List<Integer> times=new ArrayList<Integer>();
// while(matcher.find()){
// int time=strToInt(matcher.group());
// times.add(time);
// }
// String strLrc=line.replaceAll(reg, "");
// for (Iterator iterator = times.iterator(); iterator.hasNext();) {
// Integer integer = (Integer) iterator.next();
// treeMap.put(integer, strLrc);
// }
//
// }
// }
| import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
import com.sequarius.lightplayer.R;
import com.sequarius.lightplayer.object.LrcParse;
| // TODO Auto-generated method stub
TextView textView = new TextView(getActivity());
textView.setTextSize(20);
if (currentPosition == position) {
textView.setTextColor(Color.WHITE);
textView.setTextSize(23);
} else {
textView.setTextColor(Color.GRAY);
}
textView.setGravity(Gravity.CENTER);
String strLrc = mLrcs.get(position);
textView.setText(strLrc);
return textView;
}
}
/**
* ¸Ä±älrcµÄÏÔʾλÖÃ
* @param position ¸ßÁÁµÄλÖÃ
*/
public void changeLrcPostion(int position) {
mListView.smoothScrollToPosition(position + 18);
mAdapter.currentPosition = position + 9;
mAdapter.notifyDataSetChanged();
}
public void setLrc(String strFilePath){
String lrcsPath="/sdcard/lrc/"+strFilePath;
Log.i("myLog", lrcsPath);
File file = new File(lrcsPath);
| // Path: LightPlayer/src/com/sequarius/lightplayer/object/LrcParse.java
// public class LrcParse {
// private TreeMap<Integer, String> treeMap;
//
// public LrcParse(File file) throws IOException, FileNotFoundException {
// super();
// InputStreamReader isr = new InputStreamReader(new FileInputStream(file), "UTF-8");
// BufferedReader bufferedReader = new BufferedReader(isr);
// List<String> lines=new ArrayList<String>();
// String line;
// while ((line=bufferedReader.readLine())!=null) {
// lines.add(line);
// }
// treeMap=new TreeMap<>();
// for (Iterator<String> iterator = lines.iterator(); iterator.hasNext();) {
// String string = (String) iterator.next();
// parserLine(string);
// }
// bufferedReader.close();
// }
// /**
// * ÓÃÓÚ·µ»Ø½âÎöºóµÄ¸è´Ê
// * @return °´ÕÕʱ¼ä˳Ðò½âÎöºóMap¼¯ºÏ
// */
// public TreeMap<Integer, String> getLrc(){
// return treeMap;
// }
// /**
// * ½«StringÐ͵Ä×Ö·û´®½âÎö³Éʱ¼ä
// * @param timeStr ʱ¼äµÄ×Ö·û´® ¸ñʽΪ[xx:xx.xx]
// * @return ת»»ºóµÄºÁÃëintʱ¼äÖµ
// */
// private int strToInt(String timeStr){
// //È¥³ý[]
// String reg="[\\[|\\]]";
// //½âÎö·ÖÖÖλÖÃ×Ö·û´®
// timeStr=timeStr.replaceAll(reg, "");
// String[] strPre = timeStr.split(":");
// int min = Integer.parseInt(strPre[0]);
// //½âÎöÃëºÍºÁÃëλÖÃ×Ö·û´®
// int sec=0;
// int mill=0;
// if(strPre[1].contains(".")){
// String[] strNext=strPre[1].split("\\.");
// // System.out.println(s[1]);
// sec =Integer.parseInt(strNext[0]);
// mill=Integer.parseInt(strNext[1]);
// }else{
// sec=Integer.parseInt(strPre[1]);
// }
// return min*60*1000+sec*1000+mill*10;
// }
// /**
// * ½âÎöÿһÐеĸè´Ê²¢´æÈëMap
// */
// private void parserLine(String line){
// String reg ="\\[(\\d{1,2}:\\d{1,2}\\.\\d{1,2})\\]|\\[(\\d{1,2}:\\d{1,2})\\]";
// Pattern pattern = Pattern.compile(reg);
// Matcher matcher=pattern.matcher(line);
// List<Integer> times=new ArrayList<Integer>();
// while(matcher.find()){
// int time=strToInt(matcher.group());
// times.add(time);
// }
// String strLrc=line.replaceAll(reg, "");
// for (Iterator iterator = times.iterator(); iterator.hasNext();) {
// Integer integer = (Integer) iterator.next();
// treeMap.put(integer, strLrc);
// }
//
// }
// }
// Path: LightPlayer/src/com/sequarius/lightplayer/fragment/LyricFragment.java
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
import com.sequarius.lightplayer.R;
import com.sequarius.lightplayer.object.LrcParse;
// TODO Auto-generated method stub
TextView textView = new TextView(getActivity());
textView.setTextSize(20);
if (currentPosition == position) {
textView.setTextColor(Color.WHITE);
textView.setTextSize(23);
} else {
textView.setTextColor(Color.GRAY);
}
textView.setGravity(Gravity.CENTER);
String strLrc = mLrcs.get(position);
textView.setText(strLrc);
return textView;
}
}
/**
* ¸Ä±älrcµÄÏÔʾλÖÃ
* @param position ¸ßÁÁµÄλÖÃ
*/
public void changeLrcPostion(int position) {
mListView.smoothScrollToPosition(position + 18);
mAdapter.currentPosition = position + 9;
mAdapter.notifyDataSetChanged();
}
public void setLrc(String strFilePath){
String lrcsPath="/sdcard/lrc/"+strFilePath;
Log.i("myLog", lrcsPath);
File file = new File(lrcsPath);
| LrcParse lrc = null;
|
sequarius/SequariusToys | MicroBlog/src/main/java/com/sequarius/microblog/daos/impl/UserDaoImpl.java | // Path: MicroBlog/src/main/java/com/sequarius/microblog/daos/UserDao.java
// public interface UserDao {
//
// void saveUser(User user);
//
// User findUserByMail(String mail);
//
// User findUserByUsername(String username);
// }
//
// Path: MicroBlog/src/main/java/com/sequarius/microblog/entities/User.java
// @Entity
// @Table(name = "user")
// public class User implements Serializable {
// private static final long serialVersionUID = -2602075959996355784L;
//
//
// @Id
// @GenericGenerator(name="generator",strategy="increment")
// @GeneratedValue(generator="generator")
// private long id;
// @Length(min=0,max = 20,message = "{user.username.length.illegal}")
// @Column(length = 20,nullable = false,unique = true)
// private String username;
// @Length(min=6,max = 16,message="{user.password.length.illegal}")
// @Column(length = 16,nullable = false)
// private String password;
// @Column(length = 70)
// private String address;
//
//
// @Email(message = "{user.mail.format.illegal}")
// @NotEmpty(message ="{user.mail.empty.illegal}")
// @Column(length = 128,nullable = false,unique = true)
// private String email;
// @Column(length = 128)
// private String avatar;
// @Column(name = "phone_num",length = 20)
// @Pattern(regexp = "[1][34578]\\d{9}", message = "{user.phone.leagl.error}")
// private String phoneNum;
// @Column(name = "regist_time")
// private long registTime;
// @Column(name = "last_login")
// private long lastLogin;
// @Column(name ="last_login_ip",length = 15)
// private String lastLoginIp;
// @Column(length = 1)
// @Pattern(regexp = "['男''女']", message = "{user.gender.leagl.error}")
// private String gender;
//
// public static long getSerialVersionUID() {
// return serialVersionUID;
// }
//
// public String getAvatar() {
// return avatar;
// }
//
// public void setAvatar(String avatar) {
// this.avatar = avatar;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getAddress() {
// return address;
// }
//
// public void setAddress(String address) {
// this.address = address;
// }
//
// public String getPhoneNum() {
// return phoneNum;
// }
//
// public void setPhoneNum(String phoneNum) {
// this.phoneNum = phoneNum;
// }
//
// public long getRegistTime() {
// return registTime;
// }
//
// public void setRegistTime(long registTime) {
// this.registTime = registTime;
// }
//
// public long getLastLogin() {
// return lastLogin;
// }
//
// public void setLastLogin(long lastLogin) {
// this.lastLogin = lastLogin;
// }
//
// public String getLastLoginIp() {
// return lastLoginIp;
// }
//
// public void setLastLoginIp(String lastLoginIp) {
// this.lastLoginIp = lastLoginIp;
// }
//
// public String getGender() {
// return gender;
// }
//
// public void setGender(String gender) {
// this.gender = gender;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", username='" + username + '\'' +
// ", password='" + password + '\'' +
// ", address='" + address + '\'' +
// ", email='" + email + '\'' +
// ", avatar='" + avatar + '\'' +
// ", phoneNum='" + phoneNum + '\'' +
// ", registTime=" + registTime +
// ", lastLogin=" + lastLogin +
// ", lastLoginIp='" + lastLoginIp + '\'' +
// ", gender='" + gender + '\'' +
// '}';
// }
// }
| import com.sequarius.microblog.daos.UserDao;
import com.sequarius.microblog.entities.User;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.stereotype.Repository;
import java.util.List; | package com.sequarius.microblog.daos.impl;
/**
* Created by Sequarius on 2015/5/31.
*/
@Repository("userDao")
public class UserDaoImpl extends BaseDao implements UserDao {
private Session getSession(){
return getSessionFactory().getCurrentSession();
}
@Override | // Path: MicroBlog/src/main/java/com/sequarius/microblog/daos/UserDao.java
// public interface UserDao {
//
// void saveUser(User user);
//
// User findUserByMail(String mail);
//
// User findUserByUsername(String username);
// }
//
// Path: MicroBlog/src/main/java/com/sequarius/microblog/entities/User.java
// @Entity
// @Table(name = "user")
// public class User implements Serializable {
// private static final long serialVersionUID = -2602075959996355784L;
//
//
// @Id
// @GenericGenerator(name="generator",strategy="increment")
// @GeneratedValue(generator="generator")
// private long id;
// @Length(min=0,max = 20,message = "{user.username.length.illegal}")
// @Column(length = 20,nullable = false,unique = true)
// private String username;
// @Length(min=6,max = 16,message="{user.password.length.illegal}")
// @Column(length = 16,nullable = false)
// private String password;
// @Column(length = 70)
// private String address;
//
//
// @Email(message = "{user.mail.format.illegal}")
// @NotEmpty(message ="{user.mail.empty.illegal}")
// @Column(length = 128,nullable = false,unique = true)
// private String email;
// @Column(length = 128)
// private String avatar;
// @Column(name = "phone_num",length = 20)
// @Pattern(regexp = "[1][34578]\\d{9}", message = "{user.phone.leagl.error}")
// private String phoneNum;
// @Column(name = "regist_time")
// private long registTime;
// @Column(name = "last_login")
// private long lastLogin;
// @Column(name ="last_login_ip",length = 15)
// private String lastLoginIp;
// @Column(length = 1)
// @Pattern(regexp = "['男''女']", message = "{user.gender.leagl.error}")
// private String gender;
//
// public static long getSerialVersionUID() {
// return serialVersionUID;
// }
//
// public String getAvatar() {
// return avatar;
// }
//
// public void setAvatar(String avatar) {
// this.avatar = avatar;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getAddress() {
// return address;
// }
//
// public void setAddress(String address) {
// this.address = address;
// }
//
// public String getPhoneNum() {
// return phoneNum;
// }
//
// public void setPhoneNum(String phoneNum) {
// this.phoneNum = phoneNum;
// }
//
// public long getRegistTime() {
// return registTime;
// }
//
// public void setRegistTime(long registTime) {
// this.registTime = registTime;
// }
//
// public long getLastLogin() {
// return lastLogin;
// }
//
// public void setLastLogin(long lastLogin) {
// this.lastLogin = lastLogin;
// }
//
// public String getLastLoginIp() {
// return lastLoginIp;
// }
//
// public void setLastLoginIp(String lastLoginIp) {
// this.lastLoginIp = lastLoginIp;
// }
//
// public String getGender() {
// return gender;
// }
//
// public void setGender(String gender) {
// this.gender = gender;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", username='" + username + '\'' +
// ", password='" + password + '\'' +
// ", address='" + address + '\'' +
// ", email='" + email + '\'' +
// ", avatar='" + avatar + '\'' +
// ", phoneNum='" + phoneNum + '\'' +
// ", registTime=" + registTime +
// ", lastLogin=" + lastLogin +
// ", lastLoginIp='" + lastLoginIp + '\'' +
// ", gender='" + gender + '\'' +
// '}';
// }
// }
// Path: MicroBlog/src/main/java/com/sequarius/microblog/daos/impl/UserDaoImpl.java
import com.sequarius.microblog.daos.UserDao;
import com.sequarius.microblog.entities.User;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.stereotype.Repository;
import java.util.List;
package com.sequarius.microblog.daos.impl;
/**
* Created by Sequarius on 2015/5/31.
*/
@Repository("userDao")
public class UserDaoImpl extends BaseDao implements UserDao {
private Session getSession(){
return getSessionFactory().getCurrentSession();
}
@Override | public void saveUser(User user) { |
pushbit/sprockets | src/main/java/net/sf/sprockets/google/GoogleStreetView.java | // Path: src/main/java/net/sf/sprockets/google/StreetView.java
// public static final String REQUEST_IMAGE = "";
//
// Path: src/main/java/net/sf/sprockets/google/StreetView.java
// public static final String REQUEST_METADATA = "/metadata";
//
// Path: src/main/java/net/sf/sprockets/okhttp/OkHttp.java
// @Singleton
// public class OkHttp {
// private final Call.Factory mCaller;
//
// @Inject
// public OkHttp(Call.Factory caller) {
// mCaller = caller;
// }
//
// /**
// * Get a GET request for the URL.
// */
// public static Request request(String url) {
// return request(url, (String[]) null);
// }
//
// /**
// * Get a GET request for the URL and headers.
// *
// * @param headers
// * length must be a multiple of two: {@code String name, String value, ...}
// */
// public static Request request(String url, String... headers) {
// Request.Builder request = new Request.Builder().url(url);
// if (headers != null) {
// int length = headers.length;
// checkArgument(length % 2 == 0, "headers length must be a multiple of two");
// for (int i = 0; i < length; i += 2) {
// request.addHeader(headers[i], headers[i + 1]);
// }
// }
// return request.build();
// }
//
// /**
// * Get a Call for a GET request for the URL.
// */
// public Call call(String url) {
// return call(url, (String[]) null);
// }
//
// /**
// * Get a Call for a GET request for the URL and headers.
// */
// public Call call(String url, String... headers) {
// return mCaller.newCall(request(url, headers));
// }
//
// /**
// * Get a response to a GET request for the URL.
// */
// public Response response(String url) throws IOException {
// return response(url, (String[]) null);
// }
//
// /**
// * Get a response to a GET request for the URL and headers.
// */
// public Response response(String url, String... headers) throws IOException {
// return call(url, headers).execute();
// }
//
// /**
// * Download the resource at the URL and write it to the file.
// *
// * @return Response whose body has already been consumed and closed
// */
// public Response download(String url, File destination) throws IOException {
// return download(url, destination, (String[]) null);
// }
//
// /**
// * Download the resource at the URL with the headers and write it to the file.
// *
// * @return Response whose body has already been consumed and closed
// */
// public Response download(String url, File destination, String... headers) throws IOException {
// try (Response resp = response(url, headers)) {
// if (resp.isSuccessful()) {
// try (BufferedSink sink = Okio.buffer(Okio.sink(destination))) {
// resp.body().source().readAll(sink);
// }
// }
// return resp;
// }
// }
// }
| import net.sf.sprockets.okhttp.OkHttp;
import okhttp3.Call;
import okhttp3.Response;
import static com.google.gson.FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES;
import static net.sf.sprockets.google.StreetView.Params.REQUEST_IMAGE;
import static net.sf.sprockets.google.StreetView.Params.REQUEST_METADATA;
import java.io.File;
import java.io.IOException;
import javax.inject.Inject;
import javax.inject.Singleton;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder; | /*
* Copyright 2013-2017 pushbit <pushbit@gmail.com>
*
* This file is part of Sprockets.
*
* Sprockets is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* Sprockets is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with Sprockets. If
* not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.sprockets.google;
/**
* Connects to the Google Street View Image service with the provided client and authentication
* values.
*
* @since 4.0.0
*/
@Singleton
public class GoogleStreetView implements StreetView { | // Path: src/main/java/net/sf/sprockets/google/StreetView.java
// public static final String REQUEST_IMAGE = "";
//
// Path: src/main/java/net/sf/sprockets/google/StreetView.java
// public static final String REQUEST_METADATA = "/metadata";
//
// Path: src/main/java/net/sf/sprockets/okhttp/OkHttp.java
// @Singleton
// public class OkHttp {
// private final Call.Factory mCaller;
//
// @Inject
// public OkHttp(Call.Factory caller) {
// mCaller = caller;
// }
//
// /**
// * Get a GET request for the URL.
// */
// public static Request request(String url) {
// return request(url, (String[]) null);
// }
//
// /**
// * Get a GET request for the URL and headers.
// *
// * @param headers
// * length must be a multiple of two: {@code String name, String value, ...}
// */
// public static Request request(String url, String... headers) {
// Request.Builder request = new Request.Builder().url(url);
// if (headers != null) {
// int length = headers.length;
// checkArgument(length % 2 == 0, "headers length must be a multiple of two");
// for (int i = 0; i < length; i += 2) {
// request.addHeader(headers[i], headers[i + 1]);
// }
// }
// return request.build();
// }
//
// /**
// * Get a Call for a GET request for the URL.
// */
// public Call call(String url) {
// return call(url, (String[]) null);
// }
//
// /**
// * Get a Call for a GET request for the URL and headers.
// */
// public Call call(String url, String... headers) {
// return mCaller.newCall(request(url, headers));
// }
//
// /**
// * Get a response to a GET request for the URL.
// */
// public Response response(String url) throws IOException {
// return response(url, (String[]) null);
// }
//
// /**
// * Get a response to a GET request for the URL and headers.
// */
// public Response response(String url, String... headers) throws IOException {
// return call(url, headers).execute();
// }
//
// /**
// * Download the resource at the URL and write it to the file.
// *
// * @return Response whose body has already been consumed and closed
// */
// public Response download(String url, File destination) throws IOException {
// return download(url, destination, (String[]) null);
// }
//
// /**
// * Download the resource at the URL with the headers and write it to the file.
// *
// * @return Response whose body has already been consumed and closed
// */
// public Response download(String url, File destination, String... headers) throws IOException {
// try (Response resp = response(url, headers)) {
// if (resp.isSuccessful()) {
// try (BufferedSink sink = Okio.buffer(Okio.sink(destination))) {
// resp.body().source().readAll(sink);
// }
// }
// return resp;
// }
// }
// }
// Path: src/main/java/net/sf/sprockets/google/GoogleStreetView.java
import net.sf.sprockets.okhttp.OkHttp;
import okhttp3.Call;
import okhttp3.Response;
import static com.google.gson.FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES;
import static net.sf.sprockets.google.StreetView.Params.REQUEST_IMAGE;
import static net.sf.sprockets.google.StreetView.Params.REQUEST_METADATA;
import java.io.File;
import java.io.IOException;
import javax.inject.Inject;
import javax.inject.Singleton;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
/*
* Copyright 2013-2017 pushbit <pushbit@gmail.com>
*
* This file is part of Sprockets.
*
* Sprockets is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* Sprockets is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with Sprockets. If
* not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.sprockets.google;
/**
* Connects to the Google Street View Image service with the provided client and authentication
* values.
*
* @since 4.0.0
*/
@Singleton
public class GoogleStreetView implements StreetView { | private final OkHttp mClient; |
pushbit/sprockets | src/main/java/net/sf/sprockets/google/GoogleStreetView.java | // Path: src/main/java/net/sf/sprockets/google/StreetView.java
// public static final String REQUEST_IMAGE = "";
//
// Path: src/main/java/net/sf/sprockets/google/StreetView.java
// public static final String REQUEST_METADATA = "/metadata";
//
// Path: src/main/java/net/sf/sprockets/okhttp/OkHttp.java
// @Singleton
// public class OkHttp {
// private final Call.Factory mCaller;
//
// @Inject
// public OkHttp(Call.Factory caller) {
// mCaller = caller;
// }
//
// /**
// * Get a GET request for the URL.
// */
// public static Request request(String url) {
// return request(url, (String[]) null);
// }
//
// /**
// * Get a GET request for the URL and headers.
// *
// * @param headers
// * length must be a multiple of two: {@code String name, String value, ...}
// */
// public static Request request(String url, String... headers) {
// Request.Builder request = new Request.Builder().url(url);
// if (headers != null) {
// int length = headers.length;
// checkArgument(length % 2 == 0, "headers length must be a multiple of two");
// for (int i = 0; i < length; i += 2) {
// request.addHeader(headers[i], headers[i + 1]);
// }
// }
// return request.build();
// }
//
// /**
// * Get a Call for a GET request for the URL.
// */
// public Call call(String url) {
// return call(url, (String[]) null);
// }
//
// /**
// * Get a Call for a GET request for the URL and headers.
// */
// public Call call(String url, String... headers) {
// return mCaller.newCall(request(url, headers));
// }
//
// /**
// * Get a response to a GET request for the URL.
// */
// public Response response(String url) throws IOException {
// return response(url, (String[]) null);
// }
//
// /**
// * Get a response to a GET request for the URL and headers.
// */
// public Response response(String url, String... headers) throws IOException {
// return call(url, headers).execute();
// }
//
// /**
// * Download the resource at the URL and write it to the file.
// *
// * @return Response whose body has already been consumed and closed
// */
// public Response download(String url, File destination) throws IOException {
// return download(url, destination, (String[]) null);
// }
//
// /**
// * Download the resource at the URL with the headers and write it to the file.
// *
// * @return Response whose body has already been consumed and closed
// */
// public Response download(String url, File destination, String... headers) throws IOException {
// try (Response resp = response(url, headers)) {
// if (resp.isSuccessful()) {
// try (BufferedSink sink = Okio.buffer(Okio.sink(destination))) {
// resp.body().source().readAll(sink);
// }
// }
// return resp;
// }
// }
// }
| import net.sf.sprockets.okhttp.OkHttp;
import okhttp3.Call;
import okhttp3.Response;
import static com.google.gson.FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES;
import static net.sf.sprockets.google.StreetView.Params.REQUEST_IMAGE;
import static net.sf.sprockets.google.StreetView.Params.REQUEST_METADATA;
import java.io.File;
import java.io.IOException;
import javax.inject.Inject;
import javax.inject.Singleton;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder; | /*
* Copyright 2013-2017 pushbit <pushbit@gmail.com>
*
* This file is part of Sprockets.
*
* Sprockets is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* Sprockets is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with Sprockets. If
* not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.sprockets.google;
/**
* Connects to the Google Street View Image service with the provided client and authentication
* values.
*
* @since 4.0.0
*/
@Singleton
public class GoogleStreetView implements StreetView {
private final OkHttp mClient;
private final GoogleApiAuth mAuth;
private Gson mGson;
@Inject
public GoogleStreetView(OkHttp client, GoogleApiAuth auth) {
mClient = client;
mAuth = auth;
}
@Override
public Call image(Params params) { | // Path: src/main/java/net/sf/sprockets/google/StreetView.java
// public static final String REQUEST_IMAGE = "";
//
// Path: src/main/java/net/sf/sprockets/google/StreetView.java
// public static final String REQUEST_METADATA = "/metadata";
//
// Path: src/main/java/net/sf/sprockets/okhttp/OkHttp.java
// @Singleton
// public class OkHttp {
// private final Call.Factory mCaller;
//
// @Inject
// public OkHttp(Call.Factory caller) {
// mCaller = caller;
// }
//
// /**
// * Get a GET request for the URL.
// */
// public static Request request(String url) {
// return request(url, (String[]) null);
// }
//
// /**
// * Get a GET request for the URL and headers.
// *
// * @param headers
// * length must be a multiple of two: {@code String name, String value, ...}
// */
// public static Request request(String url, String... headers) {
// Request.Builder request = new Request.Builder().url(url);
// if (headers != null) {
// int length = headers.length;
// checkArgument(length % 2 == 0, "headers length must be a multiple of two");
// for (int i = 0; i < length; i += 2) {
// request.addHeader(headers[i], headers[i + 1]);
// }
// }
// return request.build();
// }
//
// /**
// * Get a Call for a GET request for the URL.
// */
// public Call call(String url) {
// return call(url, (String[]) null);
// }
//
// /**
// * Get a Call for a GET request for the URL and headers.
// */
// public Call call(String url, String... headers) {
// return mCaller.newCall(request(url, headers));
// }
//
// /**
// * Get a response to a GET request for the URL.
// */
// public Response response(String url) throws IOException {
// return response(url, (String[]) null);
// }
//
// /**
// * Get a response to a GET request for the URL and headers.
// */
// public Response response(String url, String... headers) throws IOException {
// return call(url, headers).execute();
// }
//
// /**
// * Download the resource at the URL and write it to the file.
// *
// * @return Response whose body has already been consumed and closed
// */
// public Response download(String url, File destination) throws IOException {
// return download(url, destination, (String[]) null);
// }
//
// /**
// * Download the resource at the URL with the headers and write it to the file.
// *
// * @return Response whose body has already been consumed and closed
// */
// public Response download(String url, File destination, String... headers) throws IOException {
// try (Response resp = response(url, headers)) {
// if (resp.isSuccessful()) {
// try (BufferedSink sink = Okio.buffer(Okio.sink(destination))) {
// resp.body().source().readAll(sink);
// }
// }
// return resp;
// }
// }
// }
// Path: src/main/java/net/sf/sprockets/google/GoogleStreetView.java
import net.sf.sprockets.okhttp.OkHttp;
import okhttp3.Call;
import okhttp3.Response;
import static com.google.gson.FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES;
import static net.sf.sprockets.google.StreetView.Params.REQUEST_IMAGE;
import static net.sf.sprockets.google.StreetView.Params.REQUEST_METADATA;
import java.io.File;
import java.io.IOException;
import javax.inject.Inject;
import javax.inject.Singleton;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
/*
* Copyright 2013-2017 pushbit <pushbit@gmail.com>
*
* This file is part of Sprockets.
*
* Sprockets is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* Sprockets is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with Sprockets. If
* not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.sprockets.google;
/**
* Connects to the Google Street View Image service with the provided client and authentication
* values.
*
* @since 4.0.0
*/
@Singleton
public class GoogleStreetView implements StreetView {
private final OkHttp mClient;
private final GoogleApiAuth mAuth;
private Gson mGson;
@Inject
public GoogleStreetView(OkHttp client, GoogleApiAuth auth) {
mClient = client;
mAuth = auth;
}
@Override
public Call image(Params params) { | return mClient.call(params.format(REQUEST_IMAGE, mAuth)); |
pushbit/sprockets | src/main/java/net/sf/sprockets/google/GoogleStreetView.java | // Path: src/main/java/net/sf/sprockets/google/StreetView.java
// public static final String REQUEST_IMAGE = "";
//
// Path: src/main/java/net/sf/sprockets/google/StreetView.java
// public static final String REQUEST_METADATA = "/metadata";
//
// Path: src/main/java/net/sf/sprockets/okhttp/OkHttp.java
// @Singleton
// public class OkHttp {
// private final Call.Factory mCaller;
//
// @Inject
// public OkHttp(Call.Factory caller) {
// mCaller = caller;
// }
//
// /**
// * Get a GET request for the URL.
// */
// public static Request request(String url) {
// return request(url, (String[]) null);
// }
//
// /**
// * Get a GET request for the URL and headers.
// *
// * @param headers
// * length must be a multiple of two: {@code String name, String value, ...}
// */
// public static Request request(String url, String... headers) {
// Request.Builder request = new Request.Builder().url(url);
// if (headers != null) {
// int length = headers.length;
// checkArgument(length % 2 == 0, "headers length must be a multiple of two");
// for (int i = 0; i < length; i += 2) {
// request.addHeader(headers[i], headers[i + 1]);
// }
// }
// return request.build();
// }
//
// /**
// * Get a Call for a GET request for the URL.
// */
// public Call call(String url) {
// return call(url, (String[]) null);
// }
//
// /**
// * Get a Call for a GET request for the URL and headers.
// */
// public Call call(String url, String... headers) {
// return mCaller.newCall(request(url, headers));
// }
//
// /**
// * Get a response to a GET request for the URL.
// */
// public Response response(String url) throws IOException {
// return response(url, (String[]) null);
// }
//
// /**
// * Get a response to a GET request for the URL and headers.
// */
// public Response response(String url, String... headers) throws IOException {
// return call(url, headers).execute();
// }
//
// /**
// * Download the resource at the URL and write it to the file.
// *
// * @return Response whose body has already been consumed and closed
// */
// public Response download(String url, File destination) throws IOException {
// return download(url, destination, (String[]) null);
// }
//
// /**
// * Download the resource at the URL with the headers and write it to the file.
// *
// * @return Response whose body has already been consumed and closed
// */
// public Response download(String url, File destination, String... headers) throws IOException {
// try (Response resp = response(url, headers)) {
// if (resp.isSuccessful()) {
// try (BufferedSink sink = Okio.buffer(Okio.sink(destination))) {
// resp.body().source().readAll(sink);
// }
// }
// return resp;
// }
// }
// }
| import net.sf.sprockets.okhttp.OkHttp;
import okhttp3.Call;
import okhttp3.Response;
import static com.google.gson.FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES;
import static net.sf.sprockets.google.StreetView.Params.REQUEST_IMAGE;
import static net.sf.sprockets.google.StreetView.Params.REQUEST_METADATA;
import java.io.File;
import java.io.IOException;
import javax.inject.Inject;
import javax.inject.Singleton;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder; | /*
* Copyright 2013-2017 pushbit <pushbit@gmail.com>
*
* This file is part of Sprockets.
*
* Sprockets is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* Sprockets is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with Sprockets. If
* not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.sprockets.google;
/**
* Connects to the Google Street View Image service with the provided client and authentication
* values.
*
* @since 4.0.0
*/
@Singleton
public class GoogleStreetView implements StreetView {
private final OkHttp mClient;
private final GoogleApiAuth mAuth;
private Gson mGson;
@Inject
public GoogleStreetView(OkHttp client, GoogleApiAuth auth) {
mClient = client;
mAuth = auth;
}
@Override
public Call image(Params params) {
return mClient.call(params.format(REQUEST_IMAGE, mAuth));
}
@Override
public Response image(Params params, File file) throws IOException {
return mClient.download(params.format(REQUEST_IMAGE, mAuth), file);
}
@Override
public Metadata metadata(Params params) throws IOException {
if (mGson == null) {
mGson = new GsonBuilder().registerTypeAdapterFactory(new GsonAdaptersStreetView())
.setFieldNamingPolicy(LOWER_CASE_WITH_UNDERSCORES).create();
} | // Path: src/main/java/net/sf/sprockets/google/StreetView.java
// public static final String REQUEST_IMAGE = "";
//
// Path: src/main/java/net/sf/sprockets/google/StreetView.java
// public static final String REQUEST_METADATA = "/metadata";
//
// Path: src/main/java/net/sf/sprockets/okhttp/OkHttp.java
// @Singleton
// public class OkHttp {
// private final Call.Factory mCaller;
//
// @Inject
// public OkHttp(Call.Factory caller) {
// mCaller = caller;
// }
//
// /**
// * Get a GET request for the URL.
// */
// public static Request request(String url) {
// return request(url, (String[]) null);
// }
//
// /**
// * Get a GET request for the URL and headers.
// *
// * @param headers
// * length must be a multiple of two: {@code String name, String value, ...}
// */
// public static Request request(String url, String... headers) {
// Request.Builder request = new Request.Builder().url(url);
// if (headers != null) {
// int length = headers.length;
// checkArgument(length % 2 == 0, "headers length must be a multiple of two");
// for (int i = 0; i < length; i += 2) {
// request.addHeader(headers[i], headers[i + 1]);
// }
// }
// return request.build();
// }
//
// /**
// * Get a Call for a GET request for the URL.
// */
// public Call call(String url) {
// return call(url, (String[]) null);
// }
//
// /**
// * Get a Call for a GET request for the URL and headers.
// */
// public Call call(String url, String... headers) {
// return mCaller.newCall(request(url, headers));
// }
//
// /**
// * Get a response to a GET request for the URL.
// */
// public Response response(String url) throws IOException {
// return response(url, (String[]) null);
// }
//
// /**
// * Get a response to a GET request for the URL and headers.
// */
// public Response response(String url, String... headers) throws IOException {
// return call(url, headers).execute();
// }
//
// /**
// * Download the resource at the URL and write it to the file.
// *
// * @return Response whose body has already been consumed and closed
// */
// public Response download(String url, File destination) throws IOException {
// return download(url, destination, (String[]) null);
// }
//
// /**
// * Download the resource at the URL with the headers and write it to the file.
// *
// * @return Response whose body has already been consumed and closed
// */
// public Response download(String url, File destination, String... headers) throws IOException {
// try (Response resp = response(url, headers)) {
// if (resp.isSuccessful()) {
// try (BufferedSink sink = Okio.buffer(Okio.sink(destination))) {
// resp.body().source().readAll(sink);
// }
// }
// return resp;
// }
// }
// }
// Path: src/main/java/net/sf/sprockets/google/GoogleStreetView.java
import net.sf.sprockets.okhttp.OkHttp;
import okhttp3.Call;
import okhttp3.Response;
import static com.google.gson.FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES;
import static net.sf.sprockets.google.StreetView.Params.REQUEST_IMAGE;
import static net.sf.sprockets.google.StreetView.Params.REQUEST_METADATA;
import java.io.File;
import java.io.IOException;
import javax.inject.Inject;
import javax.inject.Singleton;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
/*
* Copyright 2013-2017 pushbit <pushbit@gmail.com>
*
* This file is part of Sprockets.
*
* Sprockets is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* Sprockets is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with Sprockets. If
* not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.sprockets.google;
/**
* Connects to the Google Street View Image service with the provided client and authentication
* values.
*
* @since 4.0.0
*/
@Singleton
public class GoogleStreetView implements StreetView {
private final OkHttp mClient;
private final GoogleApiAuth mAuth;
private Gson mGson;
@Inject
public GoogleStreetView(OkHttp client, GoogleApiAuth auth) {
mClient = client;
mAuth = auth;
}
@Override
public Call image(Params params) {
return mClient.call(params.format(REQUEST_IMAGE, mAuth));
}
@Override
public Response image(Params params, File file) throws IOException {
return mClient.download(params.format(REQUEST_IMAGE, mAuth), file);
}
@Override
public Metadata metadata(Params params) throws IOException {
if (mGson == null) {
mGson = new GsonBuilder().registerTypeAdapterFactory(new GsonAdaptersStreetView())
.setFieldNamingPolicy(LOWER_CASE_WITH_UNDERSCORES).create();
} | try (Response resp = mClient.response(params.format(REQUEST_METADATA, mAuth))) { |
pushbit/sprockets | src/test/java/net/sf/sprockets/sql/ConnectionsTest.java | // Path: src/test/java/net/sf/sprockets/test/SprocketsTest.java
// public abstract class SprocketsTest {
// @Rule
// public final MockitoRule mockitoJUnitRule = MockitoJUnit.rule();
// }
//
// Path: src/main/java/net/sf/sprockets/util/logging/Loggers.java
// public class Loggers {
// private Loggers() {
// }
//
// /**
// * Get a logger for the class's package.
// */
// public static Logger get(Class<?> cls) {
// return get(cls, null);
// }
//
// /**
// * Get a logger for the class's package that uses the resource bundle for localisation.
// */
// public static Logger get(Class<?> cls, String resourceBundleName) {
// return Logger.getLogger(cls.getPackage().getName(), resourceBundleName);
// }
// }
| import static java.util.logging.Level.OFF;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.verify;
import java.sql.Connection;
import java.sql.SQLException;
import org.junit.Test;
import org.mockito.Mock;
import net.sf.sprockets.test.SprocketsTest;
import net.sf.sprockets.util.logging.Loggers; | /*
* Copyright 2017 pushbit <pushbit@gmail.com>
*
* This file is part of Sprockets.
*
* Sprockets is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* Sprockets is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with Sprockets. If
* not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.sprockets.sql;
public class ConnectionsTest extends SprocketsTest {
@Mock
private Connection mCon;
@Test
public void testClose() throws SQLException {
Connections.close(mCon);
verify(mCon).rollback();
verify(mCon).setAutoCommit(true);
verify(mCon).close();
Connections.close(null);
}
@Test
public void testCloseQuietly() throws SQLException {
Connections.closeQuietly(mCon);
| // Path: src/test/java/net/sf/sprockets/test/SprocketsTest.java
// public abstract class SprocketsTest {
// @Rule
// public final MockitoRule mockitoJUnitRule = MockitoJUnit.rule();
// }
//
// Path: src/main/java/net/sf/sprockets/util/logging/Loggers.java
// public class Loggers {
// private Loggers() {
// }
//
// /**
// * Get a logger for the class's package.
// */
// public static Logger get(Class<?> cls) {
// return get(cls, null);
// }
//
// /**
// * Get a logger for the class's package that uses the resource bundle for localisation.
// */
// public static Logger get(Class<?> cls, String resourceBundleName) {
// return Logger.getLogger(cls.getPackage().getName(), resourceBundleName);
// }
// }
// Path: src/test/java/net/sf/sprockets/sql/ConnectionsTest.java
import static java.util.logging.Level.OFF;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.verify;
import java.sql.Connection;
import java.sql.SQLException;
import org.junit.Test;
import org.mockito.Mock;
import net.sf.sprockets.test.SprocketsTest;
import net.sf.sprockets.util.logging.Loggers;
/*
* Copyright 2017 pushbit <pushbit@gmail.com>
*
* This file is part of Sprockets.
*
* Sprockets is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* Sprockets is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with Sprockets. If
* not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.sprockets.sql;
public class ConnectionsTest extends SprocketsTest {
@Mock
private Connection mCon;
@Test
public void testClose() throws SQLException {
Connections.close(mCon);
verify(mCon).rollback();
verify(mCon).setAutoCommit(true);
verify(mCon).close();
Connections.close(null);
}
@Test
public void testCloseQuietly() throws SQLException {
Connections.closeQuietly(mCon);
| Loggers.get(Connections.class).setLevel(OFF); |
pushbit/sprockets | src/main/java/net/sf/sprockets/sql/SQLite.java | // Path: src/main/java/net/sf/sprockets/util/Geos.java
// public static final double LATITUDE_DEGREE_KM = 111.132;
//
// Path: src/main/java/net/sf/sprockets/util/Geos.java
// public static final double LATITUDE_DEGREE_MI = 69.054;
//
// Path: src/main/java/net/sf/sprockets/util/MeasureUnit.java
// public static final MeasureUnit MILE = new MeasureUnit("length", "mile");
//
// Path: src/main/java/net/sf/sprockets/util/Geos.java
// public class Geos {
// /**
// * Number of kilometres in one degree of latitude at 45 degrees.
// *
// * @since 2.2.0
// */
// public static final double LATITUDE_DEGREE_KM = 111.132;
//
// /**
// * Number of miles in one degree of latitude at 45 degrees.
// *
// * @since 2.2.0
// */
// public static final double LATITUDE_DEGREE_MI = 69.054;
//
// private Geos() {
// }
//
// /**
// * Get the cosine of the latitude after converting it to radians. The result can be used to
// * improve the accuracy of geo point distance calculations. See <a href=
// * "https://web.archive.org/web/20130316112756/http://www.meridianworlddata.com/Distance-calculation.asp"
// * target="_blank">Distance Calculation</a> for more information.
// *
// * @param latitude
// * in degrees
// */
// public static double cos(double latitude) {
// return Math.cos(latitude / 57.295779579);
// }
// }
//
// Path: src/main/java/net/sf/sprockets/util/MeasureUnit.java
// public class MeasureUnit {
// /** Constant for unit of length: kilometer */
// public static final MeasureUnit KILOMETER = new MeasureUnit("length", "kilometer");
//
// /** Constant for unit of length: mile */
// public static final MeasureUnit MILE = new MeasureUnit("length", "mile");
//
// private final String type;
// private final String subType;
//
// private MeasureUnit(String type, String subType) {
// this.type = type;
// this.subType = subType;
// }
//
// /**
// * Get the type, such as "length".
// */
// public String getType() {
// return type;
// }
//
// /**
// * Get the subType, such as “foot”.
// */
// public String getSubtype() {
// return subType;
// }
//
// @Override
// public int hashCode() {
// return 31 * type.hashCode() + subType.hashCode();
// }
//
// @Override
// public boolean equals(Object rhs) {
// if (rhs == this) {
// return true;
// }
// if (!(rhs instanceof MeasureUnit)) {
// return false;
// }
// MeasureUnit c = (MeasureUnit) rhs;
// return type.equals(c.type) && subType.equals(c.subType);
// }
//
// @Override
// public String toString() {
// return type + "-" + subType;
// }
// }
| import org.apache.commons.lang3.time.FastDateFormat;
import net.sf.sprockets.util.Geos;
import net.sf.sprockets.util.MeasureUnit;
import static java.text.Normalizer.Form.NFD;
import static java.util.Locale.US;
import static net.sf.sprockets.util.Geos.LATITUDE_DEGREE_KM;
import static net.sf.sprockets.util.Geos.LATITUDE_DEGREE_MI;
import static net.sf.sprockets.util.MeasureUnit.MILE;
import java.text.Normalizer;
import java.util.Locale;
import java.util.TimeZone;
import java.util.regex.Pattern;
import javax.annotation.Nullable; | * Remove diacritics from the string and convert it to upper case.
*/
public static String normalise(String s) {
if (sDiacritics == null) {
sDiacritics = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
}
return sDiacritics.matcher(Normalizer.normalize(s, NFD)).replaceAll("").toUpperCase(US);
}
/**
* Adapted from <a href=
* "https://web.archive.org/web/20130316112756/http://www.meridianworlddata.com/Distance-calculation.asp"
* >Improved approximate distance</a>.
*/
private static final String sDistance = "(%s * (%s - %s)) * (%s * (%s - %s)) + "
+ "(%s * (%s - %s) * %s) * (%s * (%s - %s) * %s) AS %s";
/**
* Get a result column for the squared distance from the row coordinates to the supplied
* coordinates. SQLite doesn't have a square root core function, so this must be applied in Java
* when reading the result column value.
*
* @param latitudeCosineColumn
* see {@link Geos#cos(double)}
* @param unit
* KILOMETER or MILE
* @param alias
* result column name
*/
public static String distance(String latitudeColumn, String longitudeColumn, | // Path: src/main/java/net/sf/sprockets/util/Geos.java
// public static final double LATITUDE_DEGREE_KM = 111.132;
//
// Path: src/main/java/net/sf/sprockets/util/Geos.java
// public static final double LATITUDE_DEGREE_MI = 69.054;
//
// Path: src/main/java/net/sf/sprockets/util/MeasureUnit.java
// public static final MeasureUnit MILE = new MeasureUnit("length", "mile");
//
// Path: src/main/java/net/sf/sprockets/util/Geos.java
// public class Geos {
// /**
// * Number of kilometres in one degree of latitude at 45 degrees.
// *
// * @since 2.2.0
// */
// public static final double LATITUDE_DEGREE_KM = 111.132;
//
// /**
// * Number of miles in one degree of latitude at 45 degrees.
// *
// * @since 2.2.0
// */
// public static final double LATITUDE_DEGREE_MI = 69.054;
//
// private Geos() {
// }
//
// /**
// * Get the cosine of the latitude after converting it to radians. The result can be used to
// * improve the accuracy of geo point distance calculations. See <a href=
// * "https://web.archive.org/web/20130316112756/http://www.meridianworlddata.com/Distance-calculation.asp"
// * target="_blank">Distance Calculation</a> for more information.
// *
// * @param latitude
// * in degrees
// */
// public static double cos(double latitude) {
// return Math.cos(latitude / 57.295779579);
// }
// }
//
// Path: src/main/java/net/sf/sprockets/util/MeasureUnit.java
// public class MeasureUnit {
// /** Constant for unit of length: kilometer */
// public static final MeasureUnit KILOMETER = new MeasureUnit("length", "kilometer");
//
// /** Constant for unit of length: mile */
// public static final MeasureUnit MILE = new MeasureUnit("length", "mile");
//
// private final String type;
// private final String subType;
//
// private MeasureUnit(String type, String subType) {
// this.type = type;
// this.subType = subType;
// }
//
// /**
// * Get the type, such as "length".
// */
// public String getType() {
// return type;
// }
//
// /**
// * Get the subType, such as “foot”.
// */
// public String getSubtype() {
// return subType;
// }
//
// @Override
// public int hashCode() {
// return 31 * type.hashCode() + subType.hashCode();
// }
//
// @Override
// public boolean equals(Object rhs) {
// if (rhs == this) {
// return true;
// }
// if (!(rhs instanceof MeasureUnit)) {
// return false;
// }
// MeasureUnit c = (MeasureUnit) rhs;
// return type.equals(c.type) && subType.equals(c.subType);
// }
//
// @Override
// public String toString() {
// return type + "-" + subType;
// }
// }
// Path: src/main/java/net/sf/sprockets/sql/SQLite.java
import org.apache.commons.lang3.time.FastDateFormat;
import net.sf.sprockets.util.Geos;
import net.sf.sprockets.util.MeasureUnit;
import static java.text.Normalizer.Form.NFD;
import static java.util.Locale.US;
import static net.sf.sprockets.util.Geos.LATITUDE_DEGREE_KM;
import static net.sf.sprockets.util.Geos.LATITUDE_DEGREE_MI;
import static net.sf.sprockets.util.MeasureUnit.MILE;
import java.text.Normalizer;
import java.util.Locale;
import java.util.TimeZone;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
* Remove diacritics from the string and convert it to upper case.
*/
public static String normalise(String s) {
if (sDiacritics == null) {
sDiacritics = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
}
return sDiacritics.matcher(Normalizer.normalize(s, NFD)).replaceAll("").toUpperCase(US);
}
/**
* Adapted from <a href=
* "https://web.archive.org/web/20130316112756/http://www.meridianworlddata.com/Distance-calculation.asp"
* >Improved approximate distance</a>.
*/
private static final String sDistance = "(%s * (%s - %s)) * (%s * (%s - %s)) + "
+ "(%s * (%s - %s) * %s) * (%s * (%s - %s) * %s) AS %s";
/**
* Get a result column for the squared distance from the row coordinates to the supplied
* coordinates. SQLite doesn't have a square root core function, so this must be applied in Java
* when reading the result column value.
*
* @param latitudeCosineColumn
* see {@link Geos#cos(double)}
* @param unit
* KILOMETER or MILE
* @param alias
* result column name
*/
public static String distance(String latitudeColumn, String longitudeColumn, | String latitudeCosineColumn, double latitude, double longitude, MeasureUnit unit, |
pushbit/sprockets | src/main/java/net/sf/sprockets/sql/SQLite.java | // Path: src/main/java/net/sf/sprockets/util/Geos.java
// public static final double LATITUDE_DEGREE_KM = 111.132;
//
// Path: src/main/java/net/sf/sprockets/util/Geos.java
// public static final double LATITUDE_DEGREE_MI = 69.054;
//
// Path: src/main/java/net/sf/sprockets/util/MeasureUnit.java
// public static final MeasureUnit MILE = new MeasureUnit("length", "mile");
//
// Path: src/main/java/net/sf/sprockets/util/Geos.java
// public class Geos {
// /**
// * Number of kilometres in one degree of latitude at 45 degrees.
// *
// * @since 2.2.0
// */
// public static final double LATITUDE_DEGREE_KM = 111.132;
//
// /**
// * Number of miles in one degree of latitude at 45 degrees.
// *
// * @since 2.2.0
// */
// public static final double LATITUDE_DEGREE_MI = 69.054;
//
// private Geos() {
// }
//
// /**
// * Get the cosine of the latitude after converting it to radians. The result can be used to
// * improve the accuracy of geo point distance calculations. See <a href=
// * "https://web.archive.org/web/20130316112756/http://www.meridianworlddata.com/Distance-calculation.asp"
// * target="_blank">Distance Calculation</a> for more information.
// *
// * @param latitude
// * in degrees
// */
// public static double cos(double latitude) {
// return Math.cos(latitude / 57.295779579);
// }
// }
//
// Path: src/main/java/net/sf/sprockets/util/MeasureUnit.java
// public class MeasureUnit {
// /** Constant for unit of length: kilometer */
// public static final MeasureUnit KILOMETER = new MeasureUnit("length", "kilometer");
//
// /** Constant for unit of length: mile */
// public static final MeasureUnit MILE = new MeasureUnit("length", "mile");
//
// private final String type;
// private final String subType;
//
// private MeasureUnit(String type, String subType) {
// this.type = type;
// this.subType = subType;
// }
//
// /**
// * Get the type, such as "length".
// */
// public String getType() {
// return type;
// }
//
// /**
// * Get the subType, such as “foot”.
// */
// public String getSubtype() {
// return subType;
// }
//
// @Override
// public int hashCode() {
// return 31 * type.hashCode() + subType.hashCode();
// }
//
// @Override
// public boolean equals(Object rhs) {
// if (rhs == this) {
// return true;
// }
// if (!(rhs instanceof MeasureUnit)) {
// return false;
// }
// MeasureUnit c = (MeasureUnit) rhs;
// return type.equals(c.type) && subType.equals(c.subType);
// }
//
// @Override
// public String toString() {
// return type + "-" + subType;
// }
// }
| import org.apache.commons.lang3.time.FastDateFormat;
import net.sf.sprockets.util.Geos;
import net.sf.sprockets.util.MeasureUnit;
import static java.text.Normalizer.Form.NFD;
import static java.util.Locale.US;
import static net.sf.sprockets.util.Geos.LATITUDE_DEGREE_KM;
import static net.sf.sprockets.util.Geos.LATITUDE_DEGREE_MI;
import static net.sf.sprockets.util.MeasureUnit.MILE;
import java.text.Normalizer;
import java.util.Locale;
import java.util.TimeZone;
import java.util.regex.Pattern;
import javax.annotation.Nullable; | public static String normalise(String s) {
if (sDiacritics == null) {
sDiacritics = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
}
return sDiacritics.matcher(Normalizer.normalize(s, NFD)).replaceAll("").toUpperCase(US);
}
/**
* Adapted from <a href=
* "https://web.archive.org/web/20130316112756/http://www.meridianworlddata.com/Distance-calculation.asp"
* >Improved approximate distance</a>.
*/
private static final String sDistance = "(%s * (%s - %s)) * (%s * (%s - %s)) + "
+ "(%s * (%s - %s) * %s) * (%s * (%s - %s) * %s) AS %s";
/**
* Get a result column for the squared distance from the row coordinates to the supplied
* coordinates. SQLite doesn't have a square root core function, so this must be applied in Java
* when reading the result column value.
*
* @param latitudeCosineColumn
* see {@link Geos#cos(double)}
* @param unit
* KILOMETER or MILE
* @param alias
* result column name
*/
public static String distance(String latitudeColumn, String longitudeColumn,
String latitudeCosineColumn, double latitude, double longitude, MeasureUnit unit,
String alias) { | // Path: src/main/java/net/sf/sprockets/util/Geos.java
// public static final double LATITUDE_DEGREE_KM = 111.132;
//
// Path: src/main/java/net/sf/sprockets/util/Geos.java
// public static final double LATITUDE_DEGREE_MI = 69.054;
//
// Path: src/main/java/net/sf/sprockets/util/MeasureUnit.java
// public static final MeasureUnit MILE = new MeasureUnit("length", "mile");
//
// Path: src/main/java/net/sf/sprockets/util/Geos.java
// public class Geos {
// /**
// * Number of kilometres in one degree of latitude at 45 degrees.
// *
// * @since 2.2.0
// */
// public static final double LATITUDE_DEGREE_KM = 111.132;
//
// /**
// * Number of miles in one degree of latitude at 45 degrees.
// *
// * @since 2.2.0
// */
// public static final double LATITUDE_DEGREE_MI = 69.054;
//
// private Geos() {
// }
//
// /**
// * Get the cosine of the latitude after converting it to radians. The result can be used to
// * improve the accuracy of geo point distance calculations. See <a href=
// * "https://web.archive.org/web/20130316112756/http://www.meridianworlddata.com/Distance-calculation.asp"
// * target="_blank">Distance Calculation</a> for more information.
// *
// * @param latitude
// * in degrees
// */
// public static double cos(double latitude) {
// return Math.cos(latitude / 57.295779579);
// }
// }
//
// Path: src/main/java/net/sf/sprockets/util/MeasureUnit.java
// public class MeasureUnit {
// /** Constant for unit of length: kilometer */
// public static final MeasureUnit KILOMETER = new MeasureUnit("length", "kilometer");
//
// /** Constant for unit of length: mile */
// public static final MeasureUnit MILE = new MeasureUnit("length", "mile");
//
// private final String type;
// private final String subType;
//
// private MeasureUnit(String type, String subType) {
// this.type = type;
// this.subType = subType;
// }
//
// /**
// * Get the type, such as "length".
// */
// public String getType() {
// return type;
// }
//
// /**
// * Get the subType, such as “foot”.
// */
// public String getSubtype() {
// return subType;
// }
//
// @Override
// public int hashCode() {
// return 31 * type.hashCode() + subType.hashCode();
// }
//
// @Override
// public boolean equals(Object rhs) {
// if (rhs == this) {
// return true;
// }
// if (!(rhs instanceof MeasureUnit)) {
// return false;
// }
// MeasureUnit c = (MeasureUnit) rhs;
// return type.equals(c.type) && subType.equals(c.subType);
// }
//
// @Override
// public String toString() {
// return type + "-" + subType;
// }
// }
// Path: src/main/java/net/sf/sprockets/sql/SQLite.java
import org.apache.commons.lang3.time.FastDateFormat;
import net.sf.sprockets.util.Geos;
import net.sf.sprockets.util.MeasureUnit;
import static java.text.Normalizer.Form.NFD;
import static java.util.Locale.US;
import static net.sf.sprockets.util.Geos.LATITUDE_DEGREE_KM;
import static net.sf.sprockets.util.Geos.LATITUDE_DEGREE_MI;
import static net.sf.sprockets.util.MeasureUnit.MILE;
import java.text.Normalizer;
import java.util.Locale;
import java.util.TimeZone;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
public static String normalise(String s) {
if (sDiacritics == null) {
sDiacritics = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
}
return sDiacritics.matcher(Normalizer.normalize(s, NFD)).replaceAll("").toUpperCase(US);
}
/**
* Adapted from <a href=
* "https://web.archive.org/web/20130316112756/http://www.meridianworlddata.com/Distance-calculation.asp"
* >Improved approximate distance</a>.
*/
private static final String sDistance = "(%s * (%s - %s)) * (%s * (%s - %s)) + "
+ "(%s * (%s - %s) * %s) * (%s * (%s - %s) * %s) AS %s";
/**
* Get a result column for the squared distance from the row coordinates to the supplied
* coordinates. SQLite doesn't have a square root core function, so this must be applied in Java
* when reading the result column value.
*
* @param latitudeCosineColumn
* see {@link Geos#cos(double)}
* @param unit
* KILOMETER or MILE
* @param alias
* result column name
*/
public static String distance(String latitudeColumn, String longitudeColumn,
String latitudeCosineColumn, double latitude, double longitude, MeasureUnit unit,
String alias) { | double degree = unit == MILE ? LATITUDE_DEGREE_MI : LATITUDE_DEGREE_KM; |
pushbit/sprockets | src/main/java/net/sf/sprockets/sql/SQLite.java | // Path: src/main/java/net/sf/sprockets/util/Geos.java
// public static final double LATITUDE_DEGREE_KM = 111.132;
//
// Path: src/main/java/net/sf/sprockets/util/Geos.java
// public static final double LATITUDE_DEGREE_MI = 69.054;
//
// Path: src/main/java/net/sf/sprockets/util/MeasureUnit.java
// public static final MeasureUnit MILE = new MeasureUnit("length", "mile");
//
// Path: src/main/java/net/sf/sprockets/util/Geos.java
// public class Geos {
// /**
// * Number of kilometres in one degree of latitude at 45 degrees.
// *
// * @since 2.2.0
// */
// public static final double LATITUDE_DEGREE_KM = 111.132;
//
// /**
// * Number of miles in one degree of latitude at 45 degrees.
// *
// * @since 2.2.0
// */
// public static final double LATITUDE_DEGREE_MI = 69.054;
//
// private Geos() {
// }
//
// /**
// * Get the cosine of the latitude after converting it to radians. The result can be used to
// * improve the accuracy of geo point distance calculations. See <a href=
// * "https://web.archive.org/web/20130316112756/http://www.meridianworlddata.com/Distance-calculation.asp"
// * target="_blank">Distance Calculation</a> for more information.
// *
// * @param latitude
// * in degrees
// */
// public static double cos(double latitude) {
// return Math.cos(latitude / 57.295779579);
// }
// }
//
// Path: src/main/java/net/sf/sprockets/util/MeasureUnit.java
// public class MeasureUnit {
// /** Constant for unit of length: kilometer */
// public static final MeasureUnit KILOMETER = new MeasureUnit("length", "kilometer");
//
// /** Constant for unit of length: mile */
// public static final MeasureUnit MILE = new MeasureUnit("length", "mile");
//
// private final String type;
// private final String subType;
//
// private MeasureUnit(String type, String subType) {
// this.type = type;
// this.subType = subType;
// }
//
// /**
// * Get the type, such as "length".
// */
// public String getType() {
// return type;
// }
//
// /**
// * Get the subType, such as “foot”.
// */
// public String getSubtype() {
// return subType;
// }
//
// @Override
// public int hashCode() {
// return 31 * type.hashCode() + subType.hashCode();
// }
//
// @Override
// public boolean equals(Object rhs) {
// if (rhs == this) {
// return true;
// }
// if (!(rhs instanceof MeasureUnit)) {
// return false;
// }
// MeasureUnit c = (MeasureUnit) rhs;
// return type.equals(c.type) && subType.equals(c.subType);
// }
//
// @Override
// public String toString() {
// return type + "-" + subType;
// }
// }
| import org.apache.commons.lang3.time.FastDateFormat;
import net.sf.sprockets.util.Geos;
import net.sf.sprockets.util.MeasureUnit;
import static java.text.Normalizer.Form.NFD;
import static java.util.Locale.US;
import static net.sf.sprockets.util.Geos.LATITUDE_DEGREE_KM;
import static net.sf.sprockets.util.Geos.LATITUDE_DEGREE_MI;
import static net.sf.sprockets.util.MeasureUnit.MILE;
import java.text.Normalizer;
import java.util.Locale;
import java.util.TimeZone;
import java.util.regex.Pattern;
import javax.annotation.Nullable; | public static String normalise(String s) {
if (sDiacritics == null) {
sDiacritics = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
}
return sDiacritics.matcher(Normalizer.normalize(s, NFD)).replaceAll("").toUpperCase(US);
}
/**
* Adapted from <a href=
* "https://web.archive.org/web/20130316112756/http://www.meridianworlddata.com/Distance-calculation.asp"
* >Improved approximate distance</a>.
*/
private static final String sDistance = "(%s * (%s - %s)) * (%s * (%s - %s)) + "
+ "(%s * (%s - %s) * %s) * (%s * (%s - %s) * %s) AS %s";
/**
* Get a result column for the squared distance from the row coordinates to the supplied
* coordinates. SQLite doesn't have a square root core function, so this must be applied in Java
* when reading the result column value.
*
* @param latitudeCosineColumn
* see {@link Geos#cos(double)}
* @param unit
* KILOMETER or MILE
* @param alias
* result column name
*/
public static String distance(String latitudeColumn, String longitudeColumn,
String latitudeCosineColumn, double latitude, double longitude, MeasureUnit unit,
String alias) { | // Path: src/main/java/net/sf/sprockets/util/Geos.java
// public static final double LATITUDE_DEGREE_KM = 111.132;
//
// Path: src/main/java/net/sf/sprockets/util/Geos.java
// public static final double LATITUDE_DEGREE_MI = 69.054;
//
// Path: src/main/java/net/sf/sprockets/util/MeasureUnit.java
// public static final MeasureUnit MILE = new MeasureUnit("length", "mile");
//
// Path: src/main/java/net/sf/sprockets/util/Geos.java
// public class Geos {
// /**
// * Number of kilometres in one degree of latitude at 45 degrees.
// *
// * @since 2.2.0
// */
// public static final double LATITUDE_DEGREE_KM = 111.132;
//
// /**
// * Number of miles in one degree of latitude at 45 degrees.
// *
// * @since 2.2.0
// */
// public static final double LATITUDE_DEGREE_MI = 69.054;
//
// private Geos() {
// }
//
// /**
// * Get the cosine of the latitude after converting it to radians. The result can be used to
// * improve the accuracy of geo point distance calculations. See <a href=
// * "https://web.archive.org/web/20130316112756/http://www.meridianworlddata.com/Distance-calculation.asp"
// * target="_blank">Distance Calculation</a> for more information.
// *
// * @param latitude
// * in degrees
// */
// public static double cos(double latitude) {
// return Math.cos(latitude / 57.295779579);
// }
// }
//
// Path: src/main/java/net/sf/sprockets/util/MeasureUnit.java
// public class MeasureUnit {
// /** Constant for unit of length: kilometer */
// public static final MeasureUnit KILOMETER = new MeasureUnit("length", "kilometer");
//
// /** Constant for unit of length: mile */
// public static final MeasureUnit MILE = new MeasureUnit("length", "mile");
//
// private final String type;
// private final String subType;
//
// private MeasureUnit(String type, String subType) {
// this.type = type;
// this.subType = subType;
// }
//
// /**
// * Get the type, such as "length".
// */
// public String getType() {
// return type;
// }
//
// /**
// * Get the subType, such as “foot”.
// */
// public String getSubtype() {
// return subType;
// }
//
// @Override
// public int hashCode() {
// return 31 * type.hashCode() + subType.hashCode();
// }
//
// @Override
// public boolean equals(Object rhs) {
// if (rhs == this) {
// return true;
// }
// if (!(rhs instanceof MeasureUnit)) {
// return false;
// }
// MeasureUnit c = (MeasureUnit) rhs;
// return type.equals(c.type) && subType.equals(c.subType);
// }
//
// @Override
// public String toString() {
// return type + "-" + subType;
// }
// }
// Path: src/main/java/net/sf/sprockets/sql/SQLite.java
import org.apache.commons.lang3.time.FastDateFormat;
import net.sf.sprockets.util.Geos;
import net.sf.sprockets.util.MeasureUnit;
import static java.text.Normalizer.Form.NFD;
import static java.util.Locale.US;
import static net.sf.sprockets.util.Geos.LATITUDE_DEGREE_KM;
import static net.sf.sprockets.util.Geos.LATITUDE_DEGREE_MI;
import static net.sf.sprockets.util.MeasureUnit.MILE;
import java.text.Normalizer;
import java.util.Locale;
import java.util.TimeZone;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
public static String normalise(String s) {
if (sDiacritics == null) {
sDiacritics = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
}
return sDiacritics.matcher(Normalizer.normalize(s, NFD)).replaceAll("").toUpperCase(US);
}
/**
* Adapted from <a href=
* "https://web.archive.org/web/20130316112756/http://www.meridianworlddata.com/Distance-calculation.asp"
* >Improved approximate distance</a>.
*/
private static final String sDistance = "(%s * (%s - %s)) * (%s * (%s - %s)) + "
+ "(%s * (%s - %s) * %s) * (%s * (%s - %s) * %s) AS %s";
/**
* Get a result column for the squared distance from the row coordinates to the supplied
* coordinates. SQLite doesn't have a square root core function, so this must be applied in Java
* when reading the result column value.
*
* @param latitudeCosineColumn
* see {@link Geos#cos(double)}
* @param unit
* KILOMETER or MILE
* @param alias
* result column name
*/
public static String distance(String latitudeColumn, String longitudeColumn,
String latitudeCosineColumn, double latitude, double longitude, MeasureUnit unit,
String alias) { | double degree = unit == MILE ? LATITUDE_DEGREE_MI : LATITUDE_DEGREE_KM; |
pushbit/sprockets | src/main/java/net/sf/sprockets/sql/SQLite.java | // Path: src/main/java/net/sf/sprockets/util/Geos.java
// public static final double LATITUDE_DEGREE_KM = 111.132;
//
// Path: src/main/java/net/sf/sprockets/util/Geos.java
// public static final double LATITUDE_DEGREE_MI = 69.054;
//
// Path: src/main/java/net/sf/sprockets/util/MeasureUnit.java
// public static final MeasureUnit MILE = new MeasureUnit("length", "mile");
//
// Path: src/main/java/net/sf/sprockets/util/Geos.java
// public class Geos {
// /**
// * Number of kilometres in one degree of latitude at 45 degrees.
// *
// * @since 2.2.0
// */
// public static final double LATITUDE_DEGREE_KM = 111.132;
//
// /**
// * Number of miles in one degree of latitude at 45 degrees.
// *
// * @since 2.2.0
// */
// public static final double LATITUDE_DEGREE_MI = 69.054;
//
// private Geos() {
// }
//
// /**
// * Get the cosine of the latitude after converting it to radians. The result can be used to
// * improve the accuracy of geo point distance calculations. See <a href=
// * "https://web.archive.org/web/20130316112756/http://www.meridianworlddata.com/Distance-calculation.asp"
// * target="_blank">Distance Calculation</a> for more information.
// *
// * @param latitude
// * in degrees
// */
// public static double cos(double latitude) {
// return Math.cos(latitude / 57.295779579);
// }
// }
//
// Path: src/main/java/net/sf/sprockets/util/MeasureUnit.java
// public class MeasureUnit {
// /** Constant for unit of length: kilometer */
// public static final MeasureUnit KILOMETER = new MeasureUnit("length", "kilometer");
//
// /** Constant for unit of length: mile */
// public static final MeasureUnit MILE = new MeasureUnit("length", "mile");
//
// private final String type;
// private final String subType;
//
// private MeasureUnit(String type, String subType) {
// this.type = type;
// this.subType = subType;
// }
//
// /**
// * Get the type, such as "length".
// */
// public String getType() {
// return type;
// }
//
// /**
// * Get the subType, such as “foot”.
// */
// public String getSubtype() {
// return subType;
// }
//
// @Override
// public int hashCode() {
// return 31 * type.hashCode() + subType.hashCode();
// }
//
// @Override
// public boolean equals(Object rhs) {
// if (rhs == this) {
// return true;
// }
// if (!(rhs instanceof MeasureUnit)) {
// return false;
// }
// MeasureUnit c = (MeasureUnit) rhs;
// return type.equals(c.type) && subType.equals(c.subType);
// }
//
// @Override
// public String toString() {
// return type + "-" + subType;
// }
// }
| import org.apache.commons.lang3.time.FastDateFormat;
import net.sf.sprockets.util.Geos;
import net.sf.sprockets.util.MeasureUnit;
import static java.text.Normalizer.Form.NFD;
import static java.util.Locale.US;
import static net.sf.sprockets.util.Geos.LATITUDE_DEGREE_KM;
import static net.sf.sprockets.util.Geos.LATITUDE_DEGREE_MI;
import static net.sf.sprockets.util.MeasureUnit.MILE;
import java.text.Normalizer;
import java.util.Locale;
import java.util.TimeZone;
import java.util.regex.Pattern;
import javax.annotation.Nullable; | public static String normalise(String s) {
if (sDiacritics == null) {
sDiacritics = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
}
return sDiacritics.matcher(Normalizer.normalize(s, NFD)).replaceAll("").toUpperCase(US);
}
/**
* Adapted from <a href=
* "https://web.archive.org/web/20130316112756/http://www.meridianworlddata.com/Distance-calculation.asp"
* >Improved approximate distance</a>.
*/
private static final String sDistance = "(%s * (%s - %s)) * (%s * (%s - %s)) + "
+ "(%s * (%s - %s) * %s) * (%s * (%s - %s) * %s) AS %s";
/**
* Get a result column for the squared distance from the row coordinates to the supplied
* coordinates. SQLite doesn't have a square root core function, so this must be applied in Java
* when reading the result column value.
*
* @param latitudeCosineColumn
* see {@link Geos#cos(double)}
* @param unit
* KILOMETER or MILE
* @param alias
* result column name
*/
public static String distance(String latitudeColumn, String longitudeColumn,
String latitudeCosineColumn, double latitude, double longitude, MeasureUnit unit,
String alias) { | // Path: src/main/java/net/sf/sprockets/util/Geos.java
// public static final double LATITUDE_DEGREE_KM = 111.132;
//
// Path: src/main/java/net/sf/sprockets/util/Geos.java
// public static final double LATITUDE_DEGREE_MI = 69.054;
//
// Path: src/main/java/net/sf/sprockets/util/MeasureUnit.java
// public static final MeasureUnit MILE = new MeasureUnit("length", "mile");
//
// Path: src/main/java/net/sf/sprockets/util/Geos.java
// public class Geos {
// /**
// * Number of kilometres in one degree of latitude at 45 degrees.
// *
// * @since 2.2.0
// */
// public static final double LATITUDE_DEGREE_KM = 111.132;
//
// /**
// * Number of miles in one degree of latitude at 45 degrees.
// *
// * @since 2.2.0
// */
// public static final double LATITUDE_DEGREE_MI = 69.054;
//
// private Geos() {
// }
//
// /**
// * Get the cosine of the latitude after converting it to radians. The result can be used to
// * improve the accuracy of geo point distance calculations. See <a href=
// * "https://web.archive.org/web/20130316112756/http://www.meridianworlddata.com/Distance-calculation.asp"
// * target="_blank">Distance Calculation</a> for more information.
// *
// * @param latitude
// * in degrees
// */
// public static double cos(double latitude) {
// return Math.cos(latitude / 57.295779579);
// }
// }
//
// Path: src/main/java/net/sf/sprockets/util/MeasureUnit.java
// public class MeasureUnit {
// /** Constant for unit of length: kilometer */
// public static final MeasureUnit KILOMETER = new MeasureUnit("length", "kilometer");
//
// /** Constant for unit of length: mile */
// public static final MeasureUnit MILE = new MeasureUnit("length", "mile");
//
// private final String type;
// private final String subType;
//
// private MeasureUnit(String type, String subType) {
// this.type = type;
// this.subType = subType;
// }
//
// /**
// * Get the type, such as "length".
// */
// public String getType() {
// return type;
// }
//
// /**
// * Get the subType, such as “foot”.
// */
// public String getSubtype() {
// return subType;
// }
//
// @Override
// public int hashCode() {
// return 31 * type.hashCode() + subType.hashCode();
// }
//
// @Override
// public boolean equals(Object rhs) {
// if (rhs == this) {
// return true;
// }
// if (!(rhs instanceof MeasureUnit)) {
// return false;
// }
// MeasureUnit c = (MeasureUnit) rhs;
// return type.equals(c.type) && subType.equals(c.subType);
// }
//
// @Override
// public String toString() {
// return type + "-" + subType;
// }
// }
// Path: src/main/java/net/sf/sprockets/sql/SQLite.java
import org.apache.commons.lang3.time.FastDateFormat;
import net.sf.sprockets.util.Geos;
import net.sf.sprockets.util.MeasureUnit;
import static java.text.Normalizer.Form.NFD;
import static java.util.Locale.US;
import static net.sf.sprockets.util.Geos.LATITUDE_DEGREE_KM;
import static net.sf.sprockets.util.Geos.LATITUDE_DEGREE_MI;
import static net.sf.sprockets.util.MeasureUnit.MILE;
import java.text.Normalizer;
import java.util.Locale;
import java.util.TimeZone;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
public static String normalise(String s) {
if (sDiacritics == null) {
sDiacritics = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
}
return sDiacritics.matcher(Normalizer.normalize(s, NFD)).replaceAll("").toUpperCase(US);
}
/**
* Adapted from <a href=
* "https://web.archive.org/web/20130316112756/http://www.meridianworlddata.com/Distance-calculation.asp"
* >Improved approximate distance</a>.
*/
private static final String sDistance = "(%s * (%s - %s)) * (%s * (%s - %s)) + "
+ "(%s * (%s - %s) * %s) * (%s * (%s - %s) * %s) AS %s";
/**
* Get a result column for the squared distance from the row coordinates to the supplied
* coordinates. SQLite doesn't have a square root core function, so this must be applied in Java
* when reading the result column value.
*
* @param latitudeCosineColumn
* see {@link Geos#cos(double)}
* @param unit
* KILOMETER or MILE
* @param alias
* result column name
*/
public static String distance(String latitudeColumn, String longitudeColumn,
String latitudeCosineColumn, double latitude, double longitude, MeasureUnit unit,
String alias) { | double degree = unit == MILE ? LATITUDE_DEGREE_MI : LATITUDE_DEGREE_KM; |
pushbit/sprockets | src/test/java/net/sf/sprockets/util/LocalesTest.java | // Path: src/main/java/net/sf/sprockets/util/MeasureUnit.java
// public static final MeasureUnit KILOMETER = new MeasureUnit("length", "kilometer");
//
// Path: src/main/java/net/sf/sprockets/util/MeasureUnit.java
// public static final MeasureUnit MILE = new MeasureUnit("length", "mile");
| import static java.util.Locale.GERMANY;
import static java.util.Locale.US;
import static net.sf.sprockets.util.MeasureUnit.KILOMETER;
import static net.sf.sprockets.util.MeasureUnit.MILE;
import static org.junit.Assert.assertEquals;
import org.junit.Test; | /*
* Copyright 2017 pushbit <pushbit@gmail.com>
*
* This file is part of Sprockets.
*
* Sprockets is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* Sprockets is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with Sprockets. If
* not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.sprockets.util;
public class LocalesTest {
@Test
public void testDistanceUnit() { | // Path: src/main/java/net/sf/sprockets/util/MeasureUnit.java
// public static final MeasureUnit KILOMETER = new MeasureUnit("length", "kilometer");
//
// Path: src/main/java/net/sf/sprockets/util/MeasureUnit.java
// public static final MeasureUnit MILE = new MeasureUnit("length", "mile");
// Path: src/test/java/net/sf/sprockets/util/LocalesTest.java
import static java.util.Locale.GERMANY;
import static java.util.Locale.US;
import static net.sf.sprockets.util.MeasureUnit.KILOMETER;
import static net.sf.sprockets.util.MeasureUnit.MILE;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
/*
* Copyright 2017 pushbit <pushbit@gmail.com>
*
* This file is part of Sprockets.
*
* Sprockets is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* Sprockets is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with Sprockets. If
* not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.sprockets.util;
public class LocalesTest {
@Test
public void testDistanceUnit() { | assertEquals(KILOMETER, Locales.getDistanceUnit(GERMANY)); |
pushbit/sprockets | src/test/java/net/sf/sprockets/util/LocalesTest.java | // Path: src/main/java/net/sf/sprockets/util/MeasureUnit.java
// public static final MeasureUnit KILOMETER = new MeasureUnit("length", "kilometer");
//
// Path: src/main/java/net/sf/sprockets/util/MeasureUnit.java
// public static final MeasureUnit MILE = new MeasureUnit("length", "mile");
| import static java.util.Locale.GERMANY;
import static java.util.Locale.US;
import static net.sf.sprockets.util.MeasureUnit.KILOMETER;
import static net.sf.sprockets.util.MeasureUnit.MILE;
import static org.junit.Assert.assertEquals;
import org.junit.Test; | /*
* Copyright 2017 pushbit <pushbit@gmail.com>
*
* This file is part of Sprockets.
*
* Sprockets is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* Sprockets is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with Sprockets. If
* not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.sprockets.util;
public class LocalesTest {
@Test
public void testDistanceUnit() {
assertEquals(KILOMETER, Locales.getDistanceUnit(GERMANY)); | // Path: src/main/java/net/sf/sprockets/util/MeasureUnit.java
// public static final MeasureUnit KILOMETER = new MeasureUnit("length", "kilometer");
//
// Path: src/main/java/net/sf/sprockets/util/MeasureUnit.java
// public static final MeasureUnit MILE = new MeasureUnit("length", "mile");
// Path: src/test/java/net/sf/sprockets/util/LocalesTest.java
import static java.util.Locale.GERMANY;
import static java.util.Locale.US;
import static net.sf.sprockets.util.MeasureUnit.KILOMETER;
import static net.sf.sprockets.util.MeasureUnit.MILE;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
/*
* Copyright 2017 pushbit <pushbit@gmail.com>
*
* This file is part of Sprockets.
*
* Sprockets is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* Sprockets is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with Sprockets. If
* not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.sprockets.util;
public class LocalesTest {
@Test
public void testDistanceUnit() {
assertEquals(KILOMETER, Locales.getDistanceUnit(GERMANY)); | assertEquals(MILE, Locales.getDistanceUnit(US)); |
pushbit/sprockets | src/main/java/net/sf/sprockets/sql/Connections.java | // Path: src/main/java/net/sf/sprockets/util/logging/Loggers.java
// public class Loggers {
// private Loggers() {
// }
//
// /**
// * Get a logger for the class's package.
// */
// public static Logger get(Class<?> cls) {
// return get(cls, null);
// }
//
// /**
// * Get a logger for the class's package that uses the resource bundle for localisation.
// */
// public static Logger get(Class<?> cls, String resourceBundleName) {
// return Logger.getLogger(cls.getPackage().getName(), resourceBundleName);
// }
// }
| import static java.util.logging.Level.SEVERE;
import java.sql.Connection;
import java.sql.SQLException;
import javax.annotation.Nullable;
import net.sf.sprockets.util.logging.Loggers; | /*
* Copyright 2013-2016 pushbit <pushbit@gmail.com>
*
* This file is part of Sprockets.
*
* Sprockets is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* Sprockets is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with Sprockets. If
* not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.sprockets.sql;
/**
* Utility methods for working with Connections.
*
* @since 1.0.0
*/
public class Connections {
private Connections() {
}
/**
* If the connection is not in {@link Connection#getAutoCommit() auto-commit mode}, roll it back
* and put it in auto-commit mode before closing the connection.
*
* @param con
* may be null
*/
public static void close(@Nullable Connection con) throws SQLException {
if (con != null && !con.isClosed()) {
if (!con.getAutoCommit()) {
con.rollback();
con.setAutoCommit(true);
}
con.close();
}
}
/**
* {@link #close(Connection) Close} the connection and log any exceptions instead of throwing
* them.
*
* @param con
* may be null
*/
public static void closeQuietly(@Nullable Connection con) {
try {
close(con);
} catch (SQLException e) { | // Path: src/main/java/net/sf/sprockets/util/logging/Loggers.java
// public class Loggers {
// private Loggers() {
// }
//
// /**
// * Get a logger for the class's package.
// */
// public static Logger get(Class<?> cls) {
// return get(cls, null);
// }
//
// /**
// * Get a logger for the class's package that uses the resource bundle for localisation.
// */
// public static Logger get(Class<?> cls, String resourceBundleName) {
// return Logger.getLogger(cls.getPackage().getName(), resourceBundleName);
// }
// }
// Path: src/main/java/net/sf/sprockets/sql/Connections.java
import static java.util.logging.Level.SEVERE;
import java.sql.Connection;
import java.sql.SQLException;
import javax.annotation.Nullable;
import net.sf.sprockets.util.logging.Loggers;
/*
* Copyright 2013-2016 pushbit <pushbit@gmail.com>
*
* This file is part of Sprockets.
*
* Sprockets is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* Sprockets is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with Sprockets. If
* not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.sprockets.sql;
/**
* Utility methods for working with Connections.
*
* @since 1.0.0
*/
public class Connections {
private Connections() {
}
/**
* If the connection is not in {@link Connection#getAutoCommit() auto-commit mode}, roll it back
* and put it in auto-commit mode before closing the connection.
*
* @param con
* may be null
*/
public static void close(@Nullable Connection con) throws SQLException {
if (con != null && !con.isClosed()) {
if (!con.getAutoCommit()) {
con.rollback();
con.setAutoCommit(true);
}
con.close();
}
}
/**
* {@link #close(Connection) Close} the connection and log any exceptions instead of throwing
* them.
*
* @param con
* may be null
*/
public static void closeQuietly(@Nullable Connection con) {
try {
close(con);
} catch (SQLException e) { | Loggers.get(Connections.class).log(SEVERE, "closing connection", e); |
pushbit/sprockets | src/main/java/net/sf/sprockets/google/GoogleInstanceId.java | // Path: src/main/java/net/sf/sprockets/okhttp/OkHttp.java
// @Singleton
// public class OkHttp {
// private final Call.Factory mCaller;
//
// @Inject
// public OkHttp(Call.Factory caller) {
// mCaller = caller;
// }
//
// /**
// * Get a GET request for the URL.
// */
// public static Request request(String url) {
// return request(url, (String[]) null);
// }
//
// /**
// * Get a GET request for the URL and headers.
// *
// * @param headers
// * length must be a multiple of two: {@code String name, String value, ...}
// */
// public static Request request(String url, String... headers) {
// Request.Builder request = new Request.Builder().url(url);
// if (headers != null) {
// int length = headers.length;
// checkArgument(length % 2 == 0, "headers length must be a multiple of two");
// for (int i = 0; i < length; i += 2) {
// request.addHeader(headers[i], headers[i + 1]);
// }
// }
// return request.build();
// }
//
// /**
// * Get a Call for a GET request for the URL.
// */
// public Call call(String url) {
// return call(url, (String[]) null);
// }
//
// /**
// * Get a Call for a GET request for the URL and headers.
// */
// public Call call(String url, String... headers) {
// return mCaller.newCall(request(url, headers));
// }
//
// /**
// * Get a response to a GET request for the URL.
// */
// public Response response(String url) throws IOException {
// return response(url, (String[]) null);
// }
//
// /**
// * Get a response to a GET request for the URL and headers.
// */
// public Response response(String url, String... headers) throws IOException {
// return call(url, headers).execute();
// }
//
// /**
// * Download the resource at the URL and write it to the file.
// *
// * @return Response whose body has already been consumed and closed
// */
// public Response download(String url, File destination) throws IOException {
// return download(url, destination, (String[]) null);
// }
//
// /**
// * Download the resource at the URL with the headers and write it to the file.
// *
// * @return Response whose body has already been consumed and closed
// */
// public Response download(String url, File destination, String... headers) throws IOException {
// try (Response resp = response(url, headers)) {
// if (resp.isSuccessful()) {
// try (BufferedSink sink = Okio.buffer(Okio.sink(destination))) {
// resp.body().source().readAll(sink);
// }
// }
// return resp;
// }
// }
// }
| import java.io.IOException;
import javax.inject.Inject;
import javax.inject.Singleton;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import net.sf.sprockets.okhttp.OkHttp;
import okhttp3.Response; | /*
* Copyright 2017 pushbit <pushbit@gmail.com>
*
* This file is part of Sprockets.
*
* Sprockets is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* Sprockets is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with Sprockets. If
* not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.sprockets.google;
/**
* Connects to the Google Instance ID service with the provided client and Google API key.
*
* @since 4.0.0
*/
@Singleton
public class GoogleInstanceId implements InstanceId { | // Path: src/main/java/net/sf/sprockets/okhttp/OkHttp.java
// @Singleton
// public class OkHttp {
// private final Call.Factory mCaller;
//
// @Inject
// public OkHttp(Call.Factory caller) {
// mCaller = caller;
// }
//
// /**
// * Get a GET request for the URL.
// */
// public static Request request(String url) {
// return request(url, (String[]) null);
// }
//
// /**
// * Get a GET request for the URL and headers.
// *
// * @param headers
// * length must be a multiple of two: {@code String name, String value, ...}
// */
// public static Request request(String url, String... headers) {
// Request.Builder request = new Request.Builder().url(url);
// if (headers != null) {
// int length = headers.length;
// checkArgument(length % 2 == 0, "headers length must be a multiple of two");
// for (int i = 0; i < length; i += 2) {
// request.addHeader(headers[i], headers[i + 1]);
// }
// }
// return request.build();
// }
//
// /**
// * Get a Call for a GET request for the URL.
// */
// public Call call(String url) {
// return call(url, (String[]) null);
// }
//
// /**
// * Get a Call for a GET request for the URL and headers.
// */
// public Call call(String url, String... headers) {
// return mCaller.newCall(request(url, headers));
// }
//
// /**
// * Get a response to a GET request for the URL.
// */
// public Response response(String url) throws IOException {
// return response(url, (String[]) null);
// }
//
// /**
// * Get a response to a GET request for the URL and headers.
// */
// public Response response(String url, String... headers) throws IOException {
// return call(url, headers).execute();
// }
//
// /**
// * Download the resource at the URL and write it to the file.
// *
// * @return Response whose body has already been consumed and closed
// */
// public Response download(String url, File destination) throws IOException {
// return download(url, destination, (String[]) null);
// }
//
// /**
// * Download the resource at the URL with the headers and write it to the file.
// *
// * @return Response whose body has already been consumed and closed
// */
// public Response download(String url, File destination, String... headers) throws IOException {
// try (Response resp = response(url, headers)) {
// if (resp.isSuccessful()) {
// try (BufferedSink sink = Okio.buffer(Okio.sink(destination))) {
// resp.body().source().readAll(sink);
// }
// }
// return resp;
// }
// }
// }
// Path: src/main/java/net/sf/sprockets/google/GoogleInstanceId.java
import java.io.IOException;
import javax.inject.Inject;
import javax.inject.Singleton;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import net.sf.sprockets.okhttp.OkHttp;
import okhttp3.Response;
/*
* Copyright 2017 pushbit <pushbit@gmail.com>
*
* This file is part of Sprockets.
*
* Sprockets is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* Sprockets is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with Sprockets. If
* not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.sprockets.google;
/**
* Connects to the Google Instance ID service with the provided client and Google API key.
*
* @since 4.0.0
*/
@Singleton
public class GoogleInstanceId implements InstanceId { | private final OkHttp mClient; |
pushbit/sprockets | src/main/java/net/sf/sprockets/okhttp/GoogleAppEngineOkHttpClientModule.java | // Path: src/main/java/com/swizel/okhttp3/GoogleAppEngineOkHttpClient.java
// public class GoogleAppEngineOkHttpClient implements Call.Factory {
//
// @Override
// public Call newCall(Request request) {
// return new GoogleAppEngineCall(request);
// }
//
// }
| import javax.inject.Singleton;
import com.swizel.okhttp3.GoogleAppEngineOkHttpClient;
import dagger.Module;
import dagger.Provides;
import okhttp3.Call;
import okhttp3.Call.Factory; | /*
* Copyright 2017 pushbit <pushbit@gmail.com>
*
* This file is part of Sprockets.
*
* Sprockets is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* Sprockets is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with Sprockets. If
* not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.sprockets.okhttp;
/**
* Provides a Singleton {@link GoogleAppEngineOkHttpClient} instance for {@link Factory}
* dependencies.
*
* @since 4.0.0
*/
@Module
public class GoogleAppEngineOkHttpClientModule {
@Provides
@Singleton
static Call.Factory callFactory() { | // Path: src/main/java/com/swizel/okhttp3/GoogleAppEngineOkHttpClient.java
// public class GoogleAppEngineOkHttpClient implements Call.Factory {
//
// @Override
// public Call newCall(Request request) {
// return new GoogleAppEngineCall(request);
// }
//
// }
// Path: src/main/java/net/sf/sprockets/okhttp/GoogleAppEngineOkHttpClientModule.java
import javax.inject.Singleton;
import com.swizel.okhttp3.GoogleAppEngineOkHttpClient;
import dagger.Module;
import dagger.Provides;
import okhttp3.Call;
import okhttp3.Call.Factory;
/*
* Copyright 2017 pushbit <pushbit@gmail.com>
*
* This file is part of Sprockets.
*
* Sprockets is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* Sprockets is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with Sprockets. If
* not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.sprockets.okhttp;
/**
* Provides a Singleton {@link GoogleAppEngineOkHttpClient} instance for {@link Factory}
* dependencies.
*
* @since 4.0.0
*/
@Module
public class GoogleAppEngineOkHttpClientModule {
@Provides
@Singleton
static Call.Factory callFactory() { | return new GoogleAppEngineOkHttpClient(); |
pushbit/sprockets | src/main/java/net/sf/sprockets/util/Locales.java | // Path: src/main/java/net/sf/sprockets/util/MeasureUnit.java
// public static final MeasureUnit KILOMETER = new MeasureUnit("length", "kilometer");
//
// Path: src/main/java/net/sf/sprockets/util/MeasureUnit.java
// public static final MeasureUnit MILE = new MeasureUnit("length", "mile");
| import com.google.common.collect.ImmutableSet;
import static net.sf.sprockets.util.MeasureUnit.KILOMETER;
import static net.sf.sprockets.util.MeasureUnit.MILE;
import java.util.Locale; | /*
* Copyright 2015-2017 pushbit <pushbit@gmail.com>
*
* This file is part of Sprockets.
*
* Sprockets is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* Sprockets is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with Sprockets. If
* not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.sprockets.util;
/**
* Utility methods for working with Locales.
*
* @since 2.2.0
*/
public class Locales {
private Locales() {
}
/** Countries that measure distances in miles. */
private static final ImmutableSet<String> USES_MILES =
ImmutableSet.of("AS", "BS", "BZ", "DM", "FK", "GB", "GD", "GU", "KN", "KY", "LC", "LR",
"MM", "MP", "SH", "TC", "US", "VC", "VG", "VI", "WS");
/**
* Get the unit of distance that is used in the default locale, {@code KILOMETER} or
* {@code MILE}.
*/
public static MeasureUnit getDistanceUnit() {
return getDistanceUnit(Locale.getDefault());
}
/**
* Get the unit of distance that is used in the locale, {@code KILOMETER} or {@code MILE}.
*/
public static MeasureUnit getDistanceUnit(Locale locale) { | // Path: src/main/java/net/sf/sprockets/util/MeasureUnit.java
// public static final MeasureUnit KILOMETER = new MeasureUnit("length", "kilometer");
//
// Path: src/main/java/net/sf/sprockets/util/MeasureUnit.java
// public static final MeasureUnit MILE = new MeasureUnit("length", "mile");
// Path: src/main/java/net/sf/sprockets/util/Locales.java
import com.google.common.collect.ImmutableSet;
import static net.sf.sprockets.util.MeasureUnit.KILOMETER;
import static net.sf.sprockets.util.MeasureUnit.MILE;
import java.util.Locale;
/*
* Copyright 2015-2017 pushbit <pushbit@gmail.com>
*
* This file is part of Sprockets.
*
* Sprockets is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* Sprockets is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with Sprockets. If
* not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.sprockets.util;
/**
* Utility methods for working with Locales.
*
* @since 2.2.0
*/
public class Locales {
private Locales() {
}
/** Countries that measure distances in miles. */
private static final ImmutableSet<String> USES_MILES =
ImmutableSet.of("AS", "BS", "BZ", "DM", "FK", "GB", "GD", "GU", "KN", "KY", "LC", "LR",
"MM", "MP", "SH", "TC", "US", "VC", "VG", "VI", "WS");
/**
* Get the unit of distance that is used in the default locale, {@code KILOMETER} or
* {@code MILE}.
*/
public static MeasureUnit getDistanceUnit() {
return getDistanceUnit(Locale.getDefault());
}
/**
* Get the unit of distance that is used in the locale, {@code KILOMETER} or {@code MILE}.
*/
public static MeasureUnit getDistanceUnit(Locale locale) { | return USES_MILES.contains(locale.getCountry()) ? MILE : KILOMETER; |
pushbit/sprockets | src/main/java/net/sf/sprockets/util/Locales.java | // Path: src/main/java/net/sf/sprockets/util/MeasureUnit.java
// public static final MeasureUnit KILOMETER = new MeasureUnit("length", "kilometer");
//
// Path: src/main/java/net/sf/sprockets/util/MeasureUnit.java
// public static final MeasureUnit MILE = new MeasureUnit("length", "mile");
| import com.google.common.collect.ImmutableSet;
import static net.sf.sprockets.util.MeasureUnit.KILOMETER;
import static net.sf.sprockets.util.MeasureUnit.MILE;
import java.util.Locale; | /*
* Copyright 2015-2017 pushbit <pushbit@gmail.com>
*
* This file is part of Sprockets.
*
* Sprockets is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* Sprockets is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with Sprockets. If
* not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.sprockets.util;
/**
* Utility methods for working with Locales.
*
* @since 2.2.0
*/
public class Locales {
private Locales() {
}
/** Countries that measure distances in miles. */
private static final ImmutableSet<String> USES_MILES =
ImmutableSet.of("AS", "BS", "BZ", "DM", "FK", "GB", "GD", "GU", "KN", "KY", "LC", "LR",
"MM", "MP", "SH", "TC", "US", "VC", "VG", "VI", "WS");
/**
* Get the unit of distance that is used in the default locale, {@code KILOMETER} or
* {@code MILE}.
*/
public static MeasureUnit getDistanceUnit() {
return getDistanceUnit(Locale.getDefault());
}
/**
* Get the unit of distance that is used in the locale, {@code KILOMETER} or {@code MILE}.
*/
public static MeasureUnit getDistanceUnit(Locale locale) { | // Path: src/main/java/net/sf/sprockets/util/MeasureUnit.java
// public static final MeasureUnit KILOMETER = new MeasureUnit("length", "kilometer");
//
// Path: src/main/java/net/sf/sprockets/util/MeasureUnit.java
// public static final MeasureUnit MILE = new MeasureUnit("length", "mile");
// Path: src/main/java/net/sf/sprockets/util/Locales.java
import com.google.common.collect.ImmutableSet;
import static net.sf.sprockets.util.MeasureUnit.KILOMETER;
import static net.sf.sprockets.util.MeasureUnit.MILE;
import java.util.Locale;
/*
* Copyright 2015-2017 pushbit <pushbit@gmail.com>
*
* This file is part of Sprockets.
*
* Sprockets is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* Sprockets is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with Sprockets. If
* not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.sprockets.util;
/**
* Utility methods for working with Locales.
*
* @since 2.2.0
*/
public class Locales {
private Locales() {
}
/** Countries that measure distances in miles. */
private static final ImmutableSet<String> USES_MILES =
ImmutableSet.of("AS", "BS", "BZ", "DM", "FK", "GB", "GD", "GU", "KN", "KY", "LC", "LR",
"MM", "MP", "SH", "TC", "US", "VC", "VG", "VI", "WS");
/**
* Get the unit of distance that is used in the default locale, {@code KILOMETER} or
* {@code MILE}.
*/
public static MeasureUnit getDistanceUnit() {
return getDistanceUnit(Locale.getDefault());
}
/**
* Get the unit of distance that is used in the locale, {@code KILOMETER} or {@code MILE}.
*/
public static MeasureUnit getDistanceUnit(Locale locale) { | return USES_MILES.contains(locale.getCountry()) ? MILE : KILOMETER; |
aoenang/seny-devpkg | devpkg-android/src/main/java/org/senydevpkg/net/GsonRequest.java | // Path: devpkg-android/src/main/java/org/senydevpkg/utils/ALog.java
// public class ALog {
// /**
// * Application TAG,use "logcat -s TAG"
// */
// private static String TAG = "ALOG";
//
//
// private static boolean IS_FULL_CLASSNAME;
//
// /**
// * log level
// */
// private static int LOG_LEVEL = Log.VERBOSE;
//
// /**
// * print full class name or not
// *
// * @param isFullClassName
// */
// public static void setFullClassName(boolean isFullClassName) {
// ALog.IS_FULL_CLASSNAME = isFullClassName;
// }
//
// /**
// * set log level, default Log.VERBOSE
// *
// * @param level
// */
// public static void setLogLevel(int level) {
// ALog.LOG_LEVEL = level;
// }
//
// /**
// * set application TAG, default "ALOG"
// *
// * @param tag
// */
// public static void setAppTAG(String tag) {
// ALog.TAG = tag;
// }
//
//
// public static void v(String msg) {
// if (LOG_LEVEL <= Log.VERBOSE) {
// Log.v(TAG, getLogTitle() + msg);
// }
// }
//
//
// public static void d(String msg) {
// if (LOG_LEVEL <= Log.DEBUG) {
// Log.d(TAG, getLogTitle() + msg);
// }
// }
//
// public static void i(String msg) {
// if (LOG_LEVEL <= Log.INFO) {
// Log.i(TAG, getLogTitle() + msg);
// }
// }
//
// public static void w(String msg) {
// if (LOG_LEVEL <= Log.WARN) {
// Log.w(TAG, getLogTitle() + msg);
// }
// }
//
// public static void e(String msg) {
// if (LOG_LEVEL <= Log.ERROR) {
// Log.e(TAG, getLogTitle() + msg);
// }
// }
//
// /**
// * make log title
// *
// * @return
// */
// private static String getLogTitle() {
// StackTraceElement elm = Thread.currentThread().getStackTrace()[4];
// String className = elm.getClassName();
// if (!IS_FULL_CLASSNAME) {
// int dot = className.lastIndexOf('.');
// if (dot != -1) {
// className = className.substring(dot + 1);
// }
// }
// return className + "." + elm.getMethodName() + "(" + elm.getLineNumber() + ")" + ": ";
// }
//
//
// }
//
// Path: devpkg-android/src/main/java/org/senydevpkg/utils/MD5Utils.java
// public class MD5Utils {
//
// /**
// * 获取字符串加密
// *
// * @param string
// * @return
// */
// public static String encode(String string) {
// try {
// MessageDigest md = MessageDigest.getInstance("MD5");
// byte[] bs = md.digest(string.getBytes());
// StringBuilder sb = new StringBuilder();
// for (byte b : bs) {
// int num = b & 0xff;
// String hex = Integer.toHexString(num);
// if (hex.length() == 1) {
// sb.append(0);
// }
// sb.append(b);
// }
// return sb.toString();
//
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// /**
// * 获取文件MD5
// *
// * @param file
// * @return
// * @throws FileNotFoundException
// */
// public static String encode(File file) throws FileNotFoundException {
// String value = null;
// FileInputStream in = null;
// try {
// in = new FileInputStream(file);
// MappedByteBuffer byteBuffer = in.getChannel().map(FileChannel.MapMode.READ_ONLY, 0, file.length());
// MessageDigest md5 = MessageDigest.getInstance("MD5");
// md5.update(byteBuffer);
// BigInteger bi = new BigInteger(1, md5.digest());
// value = bi.toString(16);
// } catch (Exception e) {
// e.printStackTrace();
// } finally {
// if (null != in) {
// try {
// in.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
// return value;
// }
//
// }
| import android.content.Context;
import com.android.volley.AuthFailureError;
import com.android.volley.NetworkResponse;
import com.android.volley.ParseError;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.toolbox.HttpHeaderParser;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import org.senydevpkg.utils.ALog;
import org.senydevpkg.utils.MD5Utils;
import org.springframework.util.Assert;
import org.springframework.util.FileCopyUtils;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Map; | *
* @return GSON解析的对象字节码
*/
public Class<? extends T> getClazz() {
return mClazz;
}
@Override
public Map<String, String> getParams() {
return mParams;
}
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
return mHeaders == null ? super.getHeaders() : mHeaders;
}
@Override
protected void deliverResponse(T response) {
if (mListener != null) {
mListener.onResponse(response);
}
}
@Override
protected Response<T> parseNetworkResponse(NetworkResponse response) {
try {
String json = new String(
response.data,
HttpHeaderParser.parseCharset(response.headers)); | // Path: devpkg-android/src/main/java/org/senydevpkg/utils/ALog.java
// public class ALog {
// /**
// * Application TAG,use "logcat -s TAG"
// */
// private static String TAG = "ALOG";
//
//
// private static boolean IS_FULL_CLASSNAME;
//
// /**
// * log level
// */
// private static int LOG_LEVEL = Log.VERBOSE;
//
// /**
// * print full class name or not
// *
// * @param isFullClassName
// */
// public static void setFullClassName(boolean isFullClassName) {
// ALog.IS_FULL_CLASSNAME = isFullClassName;
// }
//
// /**
// * set log level, default Log.VERBOSE
// *
// * @param level
// */
// public static void setLogLevel(int level) {
// ALog.LOG_LEVEL = level;
// }
//
// /**
// * set application TAG, default "ALOG"
// *
// * @param tag
// */
// public static void setAppTAG(String tag) {
// ALog.TAG = tag;
// }
//
//
// public static void v(String msg) {
// if (LOG_LEVEL <= Log.VERBOSE) {
// Log.v(TAG, getLogTitle() + msg);
// }
// }
//
//
// public static void d(String msg) {
// if (LOG_LEVEL <= Log.DEBUG) {
// Log.d(TAG, getLogTitle() + msg);
// }
// }
//
// public static void i(String msg) {
// if (LOG_LEVEL <= Log.INFO) {
// Log.i(TAG, getLogTitle() + msg);
// }
// }
//
// public static void w(String msg) {
// if (LOG_LEVEL <= Log.WARN) {
// Log.w(TAG, getLogTitle() + msg);
// }
// }
//
// public static void e(String msg) {
// if (LOG_LEVEL <= Log.ERROR) {
// Log.e(TAG, getLogTitle() + msg);
// }
// }
//
// /**
// * make log title
// *
// * @return
// */
// private static String getLogTitle() {
// StackTraceElement elm = Thread.currentThread().getStackTrace()[4];
// String className = elm.getClassName();
// if (!IS_FULL_CLASSNAME) {
// int dot = className.lastIndexOf('.');
// if (dot != -1) {
// className = className.substring(dot + 1);
// }
// }
// return className + "." + elm.getMethodName() + "(" + elm.getLineNumber() + ")" + ": ";
// }
//
//
// }
//
// Path: devpkg-android/src/main/java/org/senydevpkg/utils/MD5Utils.java
// public class MD5Utils {
//
// /**
// * 获取字符串加密
// *
// * @param string
// * @return
// */
// public static String encode(String string) {
// try {
// MessageDigest md = MessageDigest.getInstance("MD5");
// byte[] bs = md.digest(string.getBytes());
// StringBuilder sb = new StringBuilder();
// for (byte b : bs) {
// int num = b & 0xff;
// String hex = Integer.toHexString(num);
// if (hex.length() == 1) {
// sb.append(0);
// }
// sb.append(b);
// }
// return sb.toString();
//
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// /**
// * 获取文件MD5
// *
// * @param file
// * @return
// * @throws FileNotFoundException
// */
// public static String encode(File file) throws FileNotFoundException {
// String value = null;
// FileInputStream in = null;
// try {
// in = new FileInputStream(file);
// MappedByteBuffer byteBuffer = in.getChannel().map(FileChannel.MapMode.READ_ONLY, 0, file.length());
// MessageDigest md5 = MessageDigest.getInstance("MD5");
// md5.update(byteBuffer);
// BigInteger bi = new BigInteger(1, md5.digest());
// value = bi.toString(16);
// } catch (Exception e) {
// e.printStackTrace();
// } finally {
// if (null != in) {
// try {
// in.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
// return value;
// }
//
// }
// Path: devpkg-android/src/main/java/org/senydevpkg/net/GsonRequest.java
import android.content.Context;
import com.android.volley.AuthFailureError;
import com.android.volley.NetworkResponse;
import com.android.volley.ParseError;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.toolbox.HttpHeaderParser;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import org.senydevpkg.utils.ALog;
import org.senydevpkg.utils.MD5Utils;
import org.springframework.util.Assert;
import org.springframework.util.FileCopyUtils;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Map;
*
* @return GSON解析的对象字节码
*/
public Class<? extends T> getClazz() {
return mClazz;
}
@Override
public Map<String, String> getParams() {
return mParams;
}
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
return mHeaders == null ? super.getHeaders() : mHeaders;
}
@Override
protected void deliverResponse(T response) {
if (mListener != null) {
mListener.onResponse(response);
}
}
@Override
protected Response<T> parseNetworkResponse(NetworkResponse response) {
try {
String json = new String(
response.data,
HttpHeaderParser.parseCharset(response.headers)); | ALog.d(json); |
aoenang/seny-devpkg | devpkg-android/src/main/java/org/senydevpkg/net/GsonRequest.java | // Path: devpkg-android/src/main/java/org/senydevpkg/utils/ALog.java
// public class ALog {
// /**
// * Application TAG,use "logcat -s TAG"
// */
// private static String TAG = "ALOG";
//
//
// private static boolean IS_FULL_CLASSNAME;
//
// /**
// * log level
// */
// private static int LOG_LEVEL = Log.VERBOSE;
//
// /**
// * print full class name or not
// *
// * @param isFullClassName
// */
// public static void setFullClassName(boolean isFullClassName) {
// ALog.IS_FULL_CLASSNAME = isFullClassName;
// }
//
// /**
// * set log level, default Log.VERBOSE
// *
// * @param level
// */
// public static void setLogLevel(int level) {
// ALog.LOG_LEVEL = level;
// }
//
// /**
// * set application TAG, default "ALOG"
// *
// * @param tag
// */
// public static void setAppTAG(String tag) {
// ALog.TAG = tag;
// }
//
//
// public static void v(String msg) {
// if (LOG_LEVEL <= Log.VERBOSE) {
// Log.v(TAG, getLogTitle() + msg);
// }
// }
//
//
// public static void d(String msg) {
// if (LOG_LEVEL <= Log.DEBUG) {
// Log.d(TAG, getLogTitle() + msg);
// }
// }
//
// public static void i(String msg) {
// if (LOG_LEVEL <= Log.INFO) {
// Log.i(TAG, getLogTitle() + msg);
// }
// }
//
// public static void w(String msg) {
// if (LOG_LEVEL <= Log.WARN) {
// Log.w(TAG, getLogTitle() + msg);
// }
// }
//
// public static void e(String msg) {
// if (LOG_LEVEL <= Log.ERROR) {
// Log.e(TAG, getLogTitle() + msg);
// }
// }
//
// /**
// * make log title
// *
// * @return
// */
// private static String getLogTitle() {
// StackTraceElement elm = Thread.currentThread().getStackTrace()[4];
// String className = elm.getClassName();
// if (!IS_FULL_CLASSNAME) {
// int dot = className.lastIndexOf('.');
// if (dot != -1) {
// className = className.substring(dot + 1);
// }
// }
// return className + "." + elm.getMethodName() + "(" + elm.getLineNumber() + ")" + ": ";
// }
//
//
// }
//
// Path: devpkg-android/src/main/java/org/senydevpkg/utils/MD5Utils.java
// public class MD5Utils {
//
// /**
// * 获取字符串加密
// *
// * @param string
// * @return
// */
// public static String encode(String string) {
// try {
// MessageDigest md = MessageDigest.getInstance("MD5");
// byte[] bs = md.digest(string.getBytes());
// StringBuilder sb = new StringBuilder();
// for (byte b : bs) {
// int num = b & 0xff;
// String hex = Integer.toHexString(num);
// if (hex.length() == 1) {
// sb.append(0);
// }
// sb.append(b);
// }
// return sb.toString();
//
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// /**
// * 获取文件MD5
// *
// * @param file
// * @return
// * @throws FileNotFoundException
// */
// public static String encode(File file) throws FileNotFoundException {
// String value = null;
// FileInputStream in = null;
// try {
// in = new FileInputStream(file);
// MappedByteBuffer byteBuffer = in.getChannel().map(FileChannel.MapMode.READ_ONLY, 0, file.length());
// MessageDigest md5 = MessageDigest.getInstance("MD5");
// md5.update(byteBuffer);
// BigInteger bi = new BigInteger(1, md5.digest());
// value = bi.toString(16);
// } catch (Exception e) {
// e.printStackTrace();
// } finally {
// if (null != in) {
// try {
// in.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
// return value;
// }
//
// }
| import android.content.Context;
import com.android.volley.AuthFailureError;
import com.android.volley.NetworkResponse;
import com.android.volley.ParseError;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.toolbox.HttpHeaderParser;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import org.senydevpkg.utils.ALog;
import org.senydevpkg.utils.MD5Utils;
import org.springframework.util.Assert;
import org.springframework.util.FileCopyUtils;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Map; |
@Override
public Map<String, String> getParams() {
return mParams;
}
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
return mHeaders == null ? super.getHeaders() : mHeaders;
}
@Override
protected void deliverResponse(T response) {
if (mListener != null) {
mListener.onResponse(response);
}
}
@Override
protected Response<T> parseNetworkResponse(NetworkResponse response) {
try {
String json = new String(
response.data,
HttpHeaderParser.parseCharset(response.headers));
ALog.d(json);
T result = gson.fromJson(json, mClazz);//按正常响应解析
if (mIsCache) {
//如果解析成功,并且需要缓存则将json字符串缓存到本地
ALog.i("Save response to local!"); | // Path: devpkg-android/src/main/java/org/senydevpkg/utils/ALog.java
// public class ALog {
// /**
// * Application TAG,use "logcat -s TAG"
// */
// private static String TAG = "ALOG";
//
//
// private static boolean IS_FULL_CLASSNAME;
//
// /**
// * log level
// */
// private static int LOG_LEVEL = Log.VERBOSE;
//
// /**
// * print full class name or not
// *
// * @param isFullClassName
// */
// public static void setFullClassName(boolean isFullClassName) {
// ALog.IS_FULL_CLASSNAME = isFullClassName;
// }
//
// /**
// * set log level, default Log.VERBOSE
// *
// * @param level
// */
// public static void setLogLevel(int level) {
// ALog.LOG_LEVEL = level;
// }
//
// /**
// * set application TAG, default "ALOG"
// *
// * @param tag
// */
// public static void setAppTAG(String tag) {
// ALog.TAG = tag;
// }
//
//
// public static void v(String msg) {
// if (LOG_LEVEL <= Log.VERBOSE) {
// Log.v(TAG, getLogTitle() + msg);
// }
// }
//
//
// public static void d(String msg) {
// if (LOG_LEVEL <= Log.DEBUG) {
// Log.d(TAG, getLogTitle() + msg);
// }
// }
//
// public static void i(String msg) {
// if (LOG_LEVEL <= Log.INFO) {
// Log.i(TAG, getLogTitle() + msg);
// }
// }
//
// public static void w(String msg) {
// if (LOG_LEVEL <= Log.WARN) {
// Log.w(TAG, getLogTitle() + msg);
// }
// }
//
// public static void e(String msg) {
// if (LOG_LEVEL <= Log.ERROR) {
// Log.e(TAG, getLogTitle() + msg);
// }
// }
//
// /**
// * make log title
// *
// * @return
// */
// private static String getLogTitle() {
// StackTraceElement elm = Thread.currentThread().getStackTrace()[4];
// String className = elm.getClassName();
// if (!IS_FULL_CLASSNAME) {
// int dot = className.lastIndexOf('.');
// if (dot != -1) {
// className = className.substring(dot + 1);
// }
// }
// return className + "." + elm.getMethodName() + "(" + elm.getLineNumber() + ")" + ": ";
// }
//
//
// }
//
// Path: devpkg-android/src/main/java/org/senydevpkg/utils/MD5Utils.java
// public class MD5Utils {
//
// /**
// * 获取字符串加密
// *
// * @param string
// * @return
// */
// public static String encode(String string) {
// try {
// MessageDigest md = MessageDigest.getInstance("MD5");
// byte[] bs = md.digest(string.getBytes());
// StringBuilder sb = new StringBuilder();
// for (byte b : bs) {
// int num = b & 0xff;
// String hex = Integer.toHexString(num);
// if (hex.length() == 1) {
// sb.append(0);
// }
// sb.append(b);
// }
// return sb.toString();
//
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// /**
// * 获取文件MD5
// *
// * @param file
// * @return
// * @throws FileNotFoundException
// */
// public static String encode(File file) throws FileNotFoundException {
// String value = null;
// FileInputStream in = null;
// try {
// in = new FileInputStream(file);
// MappedByteBuffer byteBuffer = in.getChannel().map(FileChannel.MapMode.READ_ONLY, 0, file.length());
// MessageDigest md5 = MessageDigest.getInstance("MD5");
// md5.update(byteBuffer);
// BigInteger bi = new BigInteger(1, md5.digest());
// value = bi.toString(16);
// } catch (Exception e) {
// e.printStackTrace();
// } finally {
// if (null != in) {
// try {
// in.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
// return value;
// }
//
// }
// Path: devpkg-android/src/main/java/org/senydevpkg/net/GsonRequest.java
import android.content.Context;
import com.android.volley.AuthFailureError;
import com.android.volley.NetworkResponse;
import com.android.volley.ParseError;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.toolbox.HttpHeaderParser;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import org.senydevpkg.utils.ALog;
import org.senydevpkg.utils.MD5Utils;
import org.springframework.util.Assert;
import org.springframework.util.FileCopyUtils;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Map;
@Override
public Map<String, String> getParams() {
return mParams;
}
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
return mHeaders == null ? super.getHeaders() : mHeaders;
}
@Override
protected void deliverResponse(T response) {
if (mListener != null) {
mListener.onResponse(response);
}
}
@Override
protected Response<T> parseNetworkResponse(NetworkResponse response) {
try {
String json = new String(
response.data,
HttpHeaderParser.parseCharset(response.headers));
ALog.d(json);
T result = gson.fromJson(json, mClazz);//按正常响应解析
if (mIsCache) {
//如果解析成功,并且需要缓存则将json字符串缓存到本地
ALog.i("Save response to local!"); | FileCopyUtils.copy(response.data, new File(mContext.getCacheDir(), "" + MD5Utils.encode(getUrl()))); |
aoenang/seny-devpkg | sample/src/main/java/org/seny/android/sample/adapter/NewsAdapter.java | // Path: devpkg-android/src/main/java/org/senydevpkg/base/AbsBaseAdapter.java
// public abstract class AbsBaseAdapter<T> extends BaseAdapter {
//
// private final Context mContext;
// private List<T> mData = new ArrayList<>();
//
// public Context getContext() {
// return mContext;
// }
//
// /**
// * 接收AbsListView要显示的数据
// *
// * @param data 要显示的数据
// */
// public AbsBaseAdapter(Context context,List<T> data) {
// mContext = context;
// this.mData = data;
// }
//
// public List<T> getData() {
// return mData;
// }
//
// /**
// * 更新AbsListView的数据
// *
// * @param newData 新数据
// */
// public void notifyDataSetChanged(List<T> newData) {
// this.mData = newData;
// notifyDataSetChanged();
// }
//
// @Override
// public int getCount() {
// return mData.size();
// }
//
// @Override
// public T getItem(int position) {
// return mData.get(position);
// }
//
// @Override
// public long getItemId(int position) {
// return position;
// }
//
// @Override
// public View getView(int position, View convertView, ViewGroup parent) {
// BaseHolder holder;
// if (convertView != null) {
// holder = (BaseHolder) convertView.getTag();
// } else {
// holder = onCreateViewHolder(parent, getItemViewType(position));
// }
// Assert.notNull(holder);
// holder.bindData(getItem(position));
// return holder.rootView;
// }
//
// /**
// * 创建ViewHolder
// *
// * @param parent The ViewGroup into which the new View will be added after it is bound to
// * an adapter position.
// * @param viewType The view type of the new View.
// * @return A new ViewHolder that holds a View of the given view type.
// */
// protected abstract BaseHolder onCreateViewHolder(ViewGroup parent, int viewType);
// }
//
// Path: devpkg-android/src/main/java/org/senydevpkg/base/BaseHolder.java
// public abstract class BaseHolder<T> {
//
// public final View rootView;
// private final Context mContext;
//
// public BaseHolder(Context context) {
// Assert.notNull(context);
// mContext = context;
// rootView = initView();
// rootView.setTag(this);
// }
//
// /**
// * 获取上下文
// *
// * @return 上下文对象
// */
// public Context getContext() {
// return mContext;
// }
//
// protected abstract View initView();
//
// /**
// * 给Holder管理的View设置数据
// *
// * @param data 数据
// */
// public void bindData(T data) {
//
// }
//
//
// }
| import org.senydevpkg.base.BaseHolder;
import java.util.List;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import org.seny.android.sample.R;
import org.seny.android.sample.resp.NewsResponse;
import org.senydevpkg.base.AbsBaseAdapter; | package org.seny.android.sample.adapter;
/**
* ━━━━ Code is far away from ━━━━━━
* () ()
* ( ) ( )
* ( ) ( )
* ┏┛┻━━━┛┻┓
* ┃ ━ ┃
* ┃ ┳┛ ┗┳ ┃
* ┃ ┻ ┃
* ┗━┓ ┏━┛
* ┃ ┃
* ┃ ┗━━━┓
* ┃ ┣┓
* ┃ ┏┛
* ┗┓┓┏━┳┓┏┛
* ┃┫┫ ┃┫┫
* ┗┻┛ ┗┻┛
* ━━━━ bug with the XYY protecting━━━
* <p/>
* Created by Seny on 2016/2/24.
*/
public class NewsAdapter extends AbsBaseAdapter<NewsResponse.DataEntity.TagEntity> {
private final Context mContext;
public NewsAdapter(Context context, List<NewsResponse.DataEntity.TagEntity> data) {
super(context,data);
mContext = context;
}
@Override | // Path: devpkg-android/src/main/java/org/senydevpkg/base/AbsBaseAdapter.java
// public abstract class AbsBaseAdapter<T> extends BaseAdapter {
//
// private final Context mContext;
// private List<T> mData = new ArrayList<>();
//
// public Context getContext() {
// return mContext;
// }
//
// /**
// * 接收AbsListView要显示的数据
// *
// * @param data 要显示的数据
// */
// public AbsBaseAdapter(Context context,List<T> data) {
// mContext = context;
// this.mData = data;
// }
//
// public List<T> getData() {
// return mData;
// }
//
// /**
// * 更新AbsListView的数据
// *
// * @param newData 新数据
// */
// public void notifyDataSetChanged(List<T> newData) {
// this.mData = newData;
// notifyDataSetChanged();
// }
//
// @Override
// public int getCount() {
// return mData.size();
// }
//
// @Override
// public T getItem(int position) {
// return mData.get(position);
// }
//
// @Override
// public long getItemId(int position) {
// return position;
// }
//
// @Override
// public View getView(int position, View convertView, ViewGroup parent) {
// BaseHolder holder;
// if (convertView != null) {
// holder = (BaseHolder) convertView.getTag();
// } else {
// holder = onCreateViewHolder(parent, getItemViewType(position));
// }
// Assert.notNull(holder);
// holder.bindData(getItem(position));
// return holder.rootView;
// }
//
// /**
// * 创建ViewHolder
// *
// * @param parent The ViewGroup into which the new View will be added after it is bound to
// * an adapter position.
// * @param viewType The view type of the new View.
// * @return A new ViewHolder that holds a View of the given view type.
// */
// protected abstract BaseHolder onCreateViewHolder(ViewGroup parent, int viewType);
// }
//
// Path: devpkg-android/src/main/java/org/senydevpkg/base/BaseHolder.java
// public abstract class BaseHolder<T> {
//
// public final View rootView;
// private final Context mContext;
//
// public BaseHolder(Context context) {
// Assert.notNull(context);
// mContext = context;
// rootView = initView();
// rootView.setTag(this);
// }
//
// /**
// * 获取上下文
// *
// * @return 上下文对象
// */
// public Context getContext() {
// return mContext;
// }
//
// protected abstract View initView();
//
// /**
// * 给Holder管理的View设置数据
// *
// * @param data 数据
// */
// public void bindData(T data) {
//
// }
//
//
// }
// Path: sample/src/main/java/org/seny/android/sample/adapter/NewsAdapter.java
import org.senydevpkg.base.BaseHolder;
import java.util.List;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import org.seny.android.sample.R;
import org.seny.android.sample.resp.NewsResponse;
import org.senydevpkg.base.AbsBaseAdapter;
package org.seny.android.sample.adapter;
/**
* ━━━━ Code is far away from ━━━━━━
* () ()
* ( ) ( )
* ( ) ( )
* ┏┛┻━━━┛┻┓
* ┃ ━ ┃
* ┃ ┳┛ ┗┳ ┃
* ┃ ┻ ┃
* ┗━┓ ┏━┛
* ┃ ┃
* ┃ ┗━━━┓
* ┃ ┣┓
* ┃ ┏┛
* ┗┓┓┏━┳┓┏┛
* ┃┫┫ ┃┫┫
* ┗┻┛ ┗┻┛
* ━━━━ bug with the XYY protecting━━━
* <p/>
* Created by Seny on 2016/2/24.
*/
public class NewsAdapter extends AbsBaseAdapter<NewsResponse.DataEntity.TagEntity> {
private final Context mContext;
public NewsAdapter(Context context, List<NewsResponse.DataEntity.TagEntity> data) {
super(context,data);
mContext = context;
}
@Override | protected BaseHolder onCreateViewHolder(ViewGroup parent, int viewType) { |
aoenang/seny-devpkg | devpkg-android/src/main/java/org/senydevpkg/net/VolleyImageCacheImpl.java | // Path: devpkg-android/src/main/java/org/senydevpkg/utils/MD5Utils.java
// public class MD5Utils {
//
// /**
// * 获取字符串加密
// *
// * @param string
// * @return
// */
// public static String encode(String string) {
// try {
// MessageDigest md = MessageDigest.getInstance("MD5");
// byte[] bs = md.digest(string.getBytes());
// StringBuilder sb = new StringBuilder();
// for (byte b : bs) {
// int num = b & 0xff;
// String hex = Integer.toHexString(num);
// if (hex.length() == 1) {
// sb.append(0);
// }
// sb.append(b);
// }
// return sb.toString();
//
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// /**
// * 获取文件MD5
// *
// * @param file
// * @return
// * @throws FileNotFoundException
// */
// public static String encode(File file) throws FileNotFoundException {
// String value = null;
// FileInputStream in = null;
// try {
// in = new FileInputStream(file);
// MappedByteBuffer byteBuffer = in.getChannel().map(FileChannel.MapMode.READ_ONLY, 0, file.length());
// MessageDigest md5 = MessageDigest.getInstance("MD5");
// md5.update(byteBuffer);
// BigInteger bi = new BigInteger(1, md5.digest());
// value = bi.toString(16);
// } catch (Exception e) {
// e.printStackTrace();
// } finally {
// if (null != in) {
// try {
// in.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
// return value;
// }
//
// }
| import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment;
import android.support.v4.util.LruCache;
import com.android.volley.toolbox.ImageLoader.ImageCache;
import org.senydevpkg.utils.MD5Utils;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream; | }
}
/**
* 该方法会判断当前sd卡是否存在,然后选择缓存地址
*
* @param context
* @return
*/
public File getDiskCacheDir(Context context, String uniqueName) {
String cachePath;
File externalCacheDir = context.getExternalCacheDir();
if ((Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
|| !Environment.isExternalStorageRemovable()) && externalCacheDir != null) {
cachePath = externalCacheDir.getPath();
} else {
cachePath = context.getCacheDir().getPath();
}
return new File(cachePath + File.separator + uniqueName);
}
/**
* 从缓存(内存缓存,磁盘缓存)中获取Bitmap
*/
@Override
public Bitmap getBitmap(String url) {
if (mLruCache.get(url) != null) {
// 从LruCache缓存中取
return mLruCache.get(url);
} else { | // Path: devpkg-android/src/main/java/org/senydevpkg/utils/MD5Utils.java
// public class MD5Utils {
//
// /**
// * 获取字符串加密
// *
// * @param string
// * @return
// */
// public static String encode(String string) {
// try {
// MessageDigest md = MessageDigest.getInstance("MD5");
// byte[] bs = md.digest(string.getBytes());
// StringBuilder sb = new StringBuilder();
// for (byte b : bs) {
// int num = b & 0xff;
// String hex = Integer.toHexString(num);
// if (hex.length() == 1) {
// sb.append(0);
// }
// sb.append(b);
// }
// return sb.toString();
//
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// /**
// * 获取文件MD5
// *
// * @param file
// * @return
// * @throws FileNotFoundException
// */
// public static String encode(File file) throws FileNotFoundException {
// String value = null;
// FileInputStream in = null;
// try {
// in = new FileInputStream(file);
// MappedByteBuffer byteBuffer = in.getChannel().map(FileChannel.MapMode.READ_ONLY, 0, file.length());
// MessageDigest md5 = MessageDigest.getInstance("MD5");
// md5.update(byteBuffer);
// BigInteger bi = new BigInteger(1, md5.digest());
// value = bi.toString(16);
// } catch (Exception e) {
// e.printStackTrace();
// } finally {
// if (null != in) {
// try {
// in.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
// return value;
// }
//
// }
// Path: devpkg-android/src/main/java/org/senydevpkg/net/VolleyImageCacheImpl.java
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment;
import android.support.v4.util.LruCache;
import com.android.volley.toolbox.ImageLoader.ImageCache;
import org.senydevpkg.utils.MD5Utils;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
}
}
/**
* 该方法会判断当前sd卡是否存在,然后选择缓存地址
*
* @param context
* @return
*/
public File getDiskCacheDir(Context context, String uniqueName) {
String cachePath;
File externalCacheDir = context.getExternalCacheDir();
if ((Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
|| !Environment.isExternalStorageRemovable()) && externalCacheDir != null) {
cachePath = externalCacheDir.getPath();
} else {
cachePath = context.getCacheDir().getPath();
}
return new File(cachePath + File.separator + uniqueName);
}
/**
* 从缓存(内存缓存,磁盘缓存)中获取Bitmap
*/
@Override
public Bitmap getBitmap(String url) {
if (mLruCache.get(url) != null) {
// 从LruCache缓存中取
return mLruCache.get(url);
} else { | String key = MD5Utils.encode(url); |
DaveRead/SequenceHunt | src/com/monead/games/android/sequence/model/SequenceHuntGameModel.java | // Path: src/com/monead/games/android/sequence/sound/SoundManager.java
// public final class SoundManager {
// /**
// * Singleton instance.
// */
// private static SoundManager instance;
//
// /**
// * The context for the sounds.
// */
// private Context context;
//
// /**
// * Whether sounds should be played.
// */
// private boolean soundEnabled;
//
// /**
// * Sound pool for game sounds.
// */
// private SoundPool sounds;
//
// /**
// * Relates the sound constants to the SoundPool ids.
// */
// private Map<Integer, Integer> soundMap;
//
// /**
// * Constructs an instance and defines the sound pool and map.
// */
// private SoundManager() {
// sounds = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
// soundMap = new HashMap<Integer, Integer>();
// }
//
// /**
// * Get the instance.
// *
// * @return The sound manager instance
// */
// public static synchronized SoundManager getInstance() {
// if (instance == null) {
// instance = new SoundManager();
// }
//
// return instance;
// }
//
// /**
// * Set the context. This must be called before any sounds can be added.
// *
// * @param pContext
// * The context for sound file access
// */
// public void setContext(final Context pContext) {
// context = pContext;
// }
//
// /**
// * Add a sound to the pool of sounds.
// *
// * @param resourceId
// * The resource id for the sound file from the context
// */
// public void addSound(final int resourceId) {
// if (context == null) {
// throw new IllegalStateException(
// "Set context before calling the addSound() method");
// }
//
// soundMap.put(resourceId, sounds.load(context, resourceId, 1));
// }
//
// /**
// * Play a sound that has been loaded into the sound collection.
// *
// * @param resourceId
// * The resource id for the sound
// */
// public void play(final int resourceId) {
// if (isSoundEnabled()) {
// sounds.play(soundMap.get(resourceId), 1.0f, 1.0f, 0, 0, 1.0f);
// }
// }
//
// /**
// * Set the sound mode (on/off).
// *
// * @param pSoundEnabled
// * True if sound is on
// */
// public void setSoundEnabled(final boolean pSoundEnabled) {
// soundEnabled = pSoundEnabled;
// }
//
// /**
// * Get the sound mode (on/off).
// *
// * @return true if sound is on
// */
// public boolean isSoundEnabled() {
// return soundEnabled;
// }
// }
| import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Random;
import com.monead.games.android.sequence.R;
import com.monead.games.android.sequence.sound.SoundManager;
import android.content.Context;
import android.graphics.Color;
import android.util.Log; | * Signal that a game is being restored.
*
* TODO Complete the implementation of the game timer
*/
public final void signalGameRestored() {
latestStartupDate = new Date();
Log.d(className, "signalGameRestored latestStartupDate.getTime ["
+ latestStartupDate.getTime() + "]");
}
/**
* Add a guess to the current try.
*
* @param color
* The chosen color
*
* @return True if there was a spot left in the current try for a guess
*/
public final boolean addGuess(final int color) {
Log.d(className, "addGuess color [" + color + "]");
if (!gameStarted) {
signalGameStart();
}
updateElapsedTime();
if (currentTry < MAX_TRYS_ALLOWED
&& currentPosit < getSequenceLength()) {
guess[currentTry][currentPosit] = color;
++currentPosit; | // Path: src/com/monead/games/android/sequence/sound/SoundManager.java
// public final class SoundManager {
// /**
// * Singleton instance.
// */
// private static SoundManager instance;
//
// /**
// * The context for the sounds.
// */
// private Context context;
//
// /**
// * Whether sounds should be played.
// */
// private boolean soundEnabled;
//
// /**
// * Sound pool for game sounds.
// */
// private SoundPool sounds;
//
// /**
// * Relates the sound constants to the SoundPool ids.
// */
// private Map<Integer, Integer> soundMap;
//
// /**
// * Constructs an instance and defines the sound pool and map.
// */
// private SoundManager() {
// sounds = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
// soundMap = new HashMap<Integer, Integer>();
// }
//
// /**
// * Get the instance.
// *
// * @return The sound manager instance
// */
// public static synchronized SoundManager getInstance() {
// if (instance == null) {
// instance = new SoundManager();
// }
//
// return instance;
// }
//
// /**
// * Set the context. This must be called before any sounds can be added.
// *
// * @param pContext
// * The context for sound file access
// */
// public void setContext(final Context pContext) {
// context = pContext;
// }
//
// /**
// * Add a sound to the pool of sounds.
// *
// * @param resourceId
// * The resource id for the sound file from the context
// */
// public void addSound(final int resourceId) {
// if (context == null) {
// throw new IllegalStateException(
// "Set context before calling the addSound() method");
// }
//
// soundMap.put(resourceId, sounds.load(context, resourceId, 1));
// }
//
// /**
// * Play a sound that has been loaded into the sound collection.
// *
// * @param resourceId
// * The resource id for the sound
// */
// public void play(final int resourceId) {
// if (isSoundEnabled()) {
// sounds.play(soundMap.get(resourceId), 1.0f, 1.0f, 0, 0, 1.0f);
// }
// }
//
// /**
// * Set the sound mode (on/off).
// *
// * @param pSoundEnabled
// * True if sound is on
// */
// public void setSoundEnabled(final boolean pSoundEnabled) {
// soundEnabled = pSoundEnabled;
// }
//
// /**
// * Get the sound mode (on/off).
// *
// * @return true if sound is on
// */
// public boolean isSoundEnabled() {
// return soundEnabled;
// }
// }
// Path: src/com/monead/games/android/sequence/model/SequenceHuntGameModel.java
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Random;
import com.monead.games.android.sequence.R;
import com.monead.games.android.sequence.sound.SoundManager;
import android.content.Context;
import android.graphics.Color;
import android.util.Log;
* Signal that a game is being restored.
*
* TODO Complete the implementation of the game timer
*/
public final void signalGameRestored() {
latestStartupDate = new Date();
Log.d(className, "signalGameRestored latestStartupDate.getTime ["
+ latestStartupDate.getTime() + "]");
}
/**
* Add a guess to the current try.
*
* @param color
* The chosen color
*
* @return True if there was a spot left in the current try for a guess
*/
public final boolean addGuess(final int color) {
Log.d(className, "addGuess color [" + color + "]");
if (!gameStarted) {
signalGameStart();
}
updateElapsedTime();
if (currentTry < MAX_TRYS_ALLOWED
&& currentPosit < getSequenceLength()) {
guess[currentTry][currentPosit] = color;
++currentPosit; | SoundManager.getInstance().play(R.raw.entry); |
ashqal/NightOwl | nightowllib/src/main/java/com/asha/nightowllib/paint/ColorBox.java | // Path: nightowllib/src/main/java/com/asha/nightowllib/paint/OwlPaintManager.java
// public static IOwlPaint queryPaint(int attrWithScope){
// Class< ? extends IOwlPaint> clz = sPaints.get(attrWithScope);
// if ( clz == null ) return null;
// IOwlPaint instance = sPaintInstances.get(clz);
// if ( instance == null ){
// instance = newInstanceSafely(clz);
// sPaintInstances.put(clz,instance);
// }
// return instance;
// }
| import android.util.SparseArray;
import android.view.View;
import static com.asha.nightowllib.paint.OwlPaintManager.queryPaint; | package com.asha.nightowllib.paint;
/**
* Created by hzqiujiadi on 15/11/7.
* hzqiujiadi ashqalcn@gmail.com
*/
public class ColorBox {
private int mMode = -1;
// may override the value, so we use SparseArray
private SparseArray<Object[]> mBox;
private ColorBox() {
mBox = new SparseArray<>(4);
}
public void put(int attr, int scope, Object... objects){
mBox.put(attr + scope, objects);
}
public void refreshSkin(int mode, View view, boolean force){
if ( force ) mMode = -1;
refreshSkin(mode,view);
}
public Object[] get(int attr, int scope){
return mBox.get( attr + scope );
}
public void refreshSkin(int mode, View view){
if ( mMode != mode ){
int size = mBox.size();
for (int i = 0; i < size; i++) {
int attrWithScope = mBox.keyAt(i);
Object[] res = mBox.valueAt(i); | // Path: nightowllib/src/main/java/com/asha/nightowllib/paint/OwlPaintManager.java
// public static IOwlPaint queryPaint(int attrWithScope){
// Class< ? extends IOwlPaint> clz = sPaints.get(attrWithScope);
// if ( clz == null ) return null;
// IOwlPaint instance = sPaintInstances.get(clz);
// if ( instance == null ){
// instance = newInstanceSafely(clz);
// sPaintInstances.put(clz,instance);
// }
// return instance;
// }
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/ColorBox.java
import android.util.SparseArray;
import android.view.View;
import static com.asha.nightowllib.paint.OwlPaintManager.queryPaint;
package com.asha.nightowllib.paint;
/**
* Created by hzqiujiadi on 15/11/7.
* hzqiujiadi ashqalcn@gmail.com
*/
public class ColorBox {
private int mMode = -1;
// may override the value, so we use SparseArray
private SparseArray<Object[]> mBox;
private ColorBox() {
mBox = new SparseArray<>(4);
}
public void put(int attr, int scope, Object... objects){
mBox.put(attr + scope, objects);
}
public void refreshSkin(int mode, View view, boolean force){
if ( force ) mMode = -1;
refreshSkin(mode,view);
}
public Object[] get(int attr, int scope){
return mBox.get( attr + scope );
}
public void refreshSkin(int mode, View view){
if ( mMode != mode ){
int size = mBox.size();
for (int i = 0; i < size; i++) {
int attrWithScope = mBox.keyAt(i);
Object[] res = mBox.valueAt(i); | IOwlPaint paint = queryPaint(attrWithScope); |
ashqal/NightOwl | nightowllib/src/main/java/com/asha/nightowllib/handler/annotations/OwlAttr.java | // Path: nightowllib/src/main/java/com/asha/nightowllib/paint/IOwlPaint.java
// public interface IOwlPaint {
// void draw(View view, Object value);
// Object[] setup(View view, TypedArray a, int attr);
// }
| import com.asha.nightowllib.paint.IOwlPaint;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.asha.nightowllib.handler.annotations;
/**
* Created by hzqiujiadi on 15/11/8.
* hzqiujiadi ashqalcn@gmail.com
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface OwlAttr { | // Path: nightowllib/src/main/java/com/asha/nightowllib/paint/IOwlPaint.java
// public interface IOwlPaint {
// void draw(View view, Object value);
// Object[] setup(View view, TypedArray a, int attr);
// }
// Path: nightowllib/src/main/java/com/asha/nightowllib/handler/annotations/OwlAttr.java
import com.asha.nightowllib.paint.IOwlPaint;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.asha.nightowllib.handler.annotations;
/**
* Created by hzqiujiadi on 15/11/8.
* hzqiujiadi ashqalcn@gmail.com
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface OwlAttr { | Class<? extends IOwlPaint> value(); |
ashqal/NightOwl | app/src/main/java/com/asha/nightowl/custom/TabLayoutHandler.java | // Path: nightowllib/src/main/java/com/asha/nightowllib/handler/impls/AbsSkinHandler.java
// public abstract class AbsSkinHandler implements ISkinHandler {
// private final static String ANDROID_XML = "http://schemas.android.com/apk/res/android";
// private static final String TAG = "AbsSkinHandler";
//
// @Override
// public void collect(int mode, View view, Context context, AttributeSet attrs) {
// Log.d(TAG, String.format("collected %s %s %s", view, context, attrs));
// ColorBox box = ColorBox.newInstance();
// onBeforeCollect(view,context,attrs,box);
//
// final Resources.Theme theme = context.getTheme();
// int systemStyleResId = 0;
// Class clz = this.getClass();
//
// // SystemStyleable
// OwlSysStyleable systemStyleable = (OwlSysStyleable) clz.getAnnotation(OwlSysStyleable.class);
// if ( systemStyleable != null ){
// String value = systemStyleable.value();
// systemStyleResId = attrs.getAttributeResourceValue(ANDROID_XML, value, 0);
// }
//
// // OwlStyleable
// Field[] fields = clz.getFields();
// for ( Field field : fields ){
// OwlStyleable owlStyleable = field.getAnnotation(OwlStyleable.class);
// if ( owlStyleable == null ) continue;
//
// Class scopeClz = field.getDeclaringClass();
// OwlAttrScope owlAttrScope = (OwlAttrScope) scopeClz.getAnnotation(OwlAttrScope.class);
// if ( owlAttrScope == null ) continue;
//
// int scope = owlAttrScope.value();
// int[] styleableResId = getStaticFieldIntArraySafely(field);
// if ( styleableResId == null ) continue;
//
// TypedArray a = theme.obtainStyledAttributes(attrs, styleableResId, 0, systemStyleResId);
// if ( a != null ){
// obtainStyle(view, box, scope, a);
// a.recycle();
// }
// }
//
// onAfterCollect(view,context,attrs,box);
// insertSkinBox(view, box);
//
// // first refresh
// box.refreshSkin(mode, view, true);
// }
//
// private void obtainStyle(View view
// , ColorBox box
// , int scope
// , TypedArray a
// ){
//
// int n = a.getIndexCount();
// for (int i = 0; i < n; i++) {
// int attr = a.getIndex(i);
//
// // look for attr
// IOwlPaint paint = queryPaint(attr+scope);
// if ( paint == null) {
// Log.d(TAG, "Can't find paint of attr:" + attr + " scope:" + scope); continue; }
// Object[] values = paint.setup(view,a,attr);
// if ( values != null ) box.put(attr, scope, values);
// }
// }
//
// protected void onBeforeCollect(View view, Context context, AttributeSet attrs, ColorBox box){}
//
// protected void onAfterCollect(View view, Context context, AttributeSet attrs, ColorBox box){}
//
// @Override
// final public void onSkinChanged(int skin, View view) {
// ColorBox box = obtainSkinBox(view);
// if ( box != null ) box.refreshSkin(skin, view);
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/ColorBox.java
// public class ColorBox {
// private int mMode = -1;
// // may override the value, so we use SparseArray
// private SparseArray<Object[]> mBox;
// private ColorBox() {
// mBox = new SparseArray<>(4);
// }
//
// public void put(int attr, int scope, Object... objects){
// mBox.put(attr + scope, objects);
// }
//
// public void refreshSkin(int mode, View view, boolean force){
// if ( force ) mMode = -1;
// refreshSkin(mode,view);
// }
//
// public Object[] get(int attr, int scope){
// return mBox.get( attr + scope );
// }
//
// public void refreshSkin(int mode, View view){
// if ( mMode != mode ){
// int size = mBox.size();
// for (int i = 0; i < size; i++) {
// int attrWithScope = mBox.keyAt(i);
// Object[] res = mBox.valueAt(i);
// IOwlPaint paint = queryPaint(attrWithScope);
// if ( paint != null ) paint.draw(view, res[mode]);
// }
// }
// mMode = mode;
// }
//
// public int getMode() {
// return mMode;
// }
//
// public static ColorBox newInstance() {
// return new ColorBox();
// }
//
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/IOwlPaint.java
// public interface IOwlPaint {
// void draw(View view, Object value);
// Object[] setup(View view, TypedArray a, int attr);
// }
| import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.support.annotation.NonNull;
import android.support.design.widget.TabLayout;
import android.util.AttributeSet;
import android.view.View;
import com.asha.nightowl.R;
import com.asha.nightowllib.handler.annotations.OwlHandle;
import com.asha.nightowllib.handler.impls.AbsSkinHandler;
import com.asha.nightowllib.paint.ColorBox;
import com.asha.nightowllib.paint.IOwlPaint; | package com.asha.nightowl.custom;
/**
* Created by hzqiujiadi on 15/11/10.
* hzqiujiadi ashqalcn@gmail.com
*/
@OwlHandle(TabLayout.class)
public class TabLayoutHandler extends AbsSkinHandler implements OwlCustomTable.OwlTabLayout {
@Override | // Path: nightowllib/src/main/java/com/asha/nightowllib/handler/impls/AbsSkinHandler.java
// public abstract class AbsSkinHandler implements ISkinHandler {
// private final static String ANDROID_XML = "http://schemas.android.com/apk/res/android";
// private static final String TAG = "AbsSkinHandler";
//
// @Override
// public void collect(int mode, View view, Context context, AttributeSet attrs) {
// Log.d(TAG, String.format("collected %s %s %s", view, context, attrs));
// ColorBox box = ColorBox.newInstance();
// onBeforeCollect(view,context,attrs,box);
//
// final Resources.Theme theme = context.getTheme();
// int systemStyleResId = 0;
// Class clz = this.getClass();
//
// // SystemStyleable
// OwlSysStyleable systemStyleable = (OwlSysStyleable) clz.getAnnotation(OwlSysStyleable.class);
// if ( systemStyleable != null ){
// String value = systemStyleable.value();
// systemStyleResId = attrs.getAttributeResourceValue(ANDROID_XML, value, 0);
// }
//
// // OwlStyleable
// Field[] fields = clz.getFields();
// for ( Field field : fields ){
// OwlStyleable owlStyleable = field.getAnnotation(OwlStyleable.class);
// if ( owlStyleable == null ) continue;
//
// Class scopeClz = field.getDeclaringClass();
// OwlAttrScope owlAttrScope = (OwlAttrScope) scopeClz.getAnnotation(OwlAttrScope.class);
// if ( owlAttrScope == null ) continue;
//
// int scope = owlAttrScope.value();
// int[] styleableResId = getStaticFieldIntArraySafely(field);
// if ( styleableResId == null ) continue;
//
// TypedArray a = theme.obtainStyledAttributes(attrs, styleableResId, 0, systemStyleResId);
// if ( a != null ){
// obtainStyle(view, box, scope, a);
// a.recycle();
// }
// }
//
// onAfterCollect(view,context,attrs,box);
// insertSkinBox(view, box);
//
// // first refresh
// box.refreshSkin(mode, view, true);
// }
//
// private void obtainStyle(View view
// , ColorBox box
// , int scope
// , TypedArray a
// ){
//
// int n = a.getIndexCount();
// for (int i = 0; i < n; i++) {
// int attr = a.getIndex(i);
//
// // look for attr
// IOwlPaint paint = queryPaint(attr+scope);
// if ( paint == null) {
// Log.d(TAG, "Can't find paint of attr:" + attr + " scope:" + scope); continue; }
// Object[] values = paint.setup(view,a,attr);
// if ( values != null ) box.put(attr, scope, values);
// }
// }
//
// protected void onBeforeCollect(View view, Context context, AttributeSet attrs, ColorBox box){}
//
// protected void onAfterCollect(View view, Context context, AttributeSet attrs, ColorBox box){}
//
// @Override
// final public void onSkinChanged(int skin, View view) {
// ColorBox box = obtainSkinBox(view);
// if ( box != null ) box.refreshSkin(skin, view);
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/ColorBox.java
// public class ColorBox {
// private int mMode = -1;
// // may override the value, so we use SparseArray
// private SparseArray<Object[]> mBox;
// private ColorBox() {
// mBox = new SparseArray<>(4);
// }
//
// public void put(int attr, int scope, Object... objects){
// mBox.put(attr + scope, objects);
// }
//
// public void refreshSkin(int mode, View view, boolean force){
// if ( force ) mMode = -1;
// refreshSkin(mode,view);
// }
//
// public Object[] get(int attr, int scope){
// return mBox.get( attr + scope );
// }
//
// public void refreshSkin(int mode, View view){
// if ( mMode != mode ){
// int size = mBox.size();
// for (int i = 0; i < size; i++) {
// int attrWithScope = mBox.keyAt(i);
// Object[] res = mBox.valueAt(i);
// IOwlPaint paint = queryPaint(attrWithScope);
// if ( paint != null ) paint.draw(view, res[mode]);
// }
// }
// mMode = mode;
// }
//
// public int getMode() {
// return mMode;
// }
//
// public static ColorBox newInstance() {
// return new ColorBox();
// }
//
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/IOwlPaint.java
// public interface IOwlPaint {
// void draw(View view, Object value);
// Object[] setup(View view, TypedArray a, int attr);
// }
// Path: app/src/main/java/com/asha/nightowl/custom/TabLayoutHandler.java
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.support.annotation.NonNull;
import android.support.design.widget.TabLayout;
import android.util.AttributeSet;
import android.view.View;
import com.asha.nightowl.R;
import com.asha.nightowllib.handler.annotations.OwlHandle;
import com.asha.nightowllib.handler.impls.AbsSkinHandler;
import com.asha.nightowllib.paint.ColorBox;
import com.asha.nightowllib.paint.IOwlPaint;
package com.asha.nightowl.custom;
/**
* Created by hzqiujiadi on 15/11/10.
* hzqiujiadi ashqalcn@gmail.com
*/
@OwlHandle(TabLayout.class)
public class TabLayoutHandler extends AbsSkinHandler implements OwlCustomTable.OwlTabLayout {
@Override | protected void onAfterCollect(View view, Context context, AttributeSet attrs, ColorBox box) { |
ashqal/NightOwl | app/src/main/java/com/asha/nightowl/custom/CardViewHandler.java | // Path: nightowllib/src/main/java/com/asha/nightowllib/handler/impls/AbsSkinHandler.java
// public abstract class AbsSkinHandler implements ISkinHandler {
// private final static String ANDROID_XML = "http://schemas.android.com/apk/res/android";
// private static final String TAG = "AbsSkinHandler";
//
// @Override
// public void collect(int mode, View view, Context context, AttributeSet attrs) {
// Log.d(TAG, String.format("collected %s %s %s", view, context, attrs));
// ColorBox box = ColorBox.newInstance();
// onBeforeCollect(view,context,attrs,box);
//
// final Resources.Theme theme = context.getTheme();
// int systemStyleResId = 0;
// Class clz = this.getClass();
//
// // SystemStyleable
// OwlSysStyleable systemStyleable = (OwlSysStyleable) clz.getAnnotation(OwlSysStyleable.class);
// if ( systemStyleable != null ){
// String value = systemStyleable.value();
// systemStyleResId = attrs.getAttributeResourceValue(ANDROID_XML, value, 0);
// }
//
// // OwlStyleable
// Field[] fields = clz.getFields();
// for ( Field field : fields ){
// OwlStyleable owlStyleable = field.getAnnotation(OwlStyleable.class);
// if ( owlStyleable == null ) continue;
//
// Class scopeClz = field.getDeclaringClass();
// OwlAttrScope owlAttrScope = (OwlAttrScope) scopeClz.getAnnotation(OwlAttrScope.class);
// if ( owlAttrScope == null ) continue;
//
// int scope = owlAttrScope.value();
// int[] styleableResId = getStaticFieldIntArraySafely(field);
// if ( styleableResId == null ) continue;
//
// TypedArray a = theme.obtainStyledAttributes(attrs, styleableResId, 0, systemStyleResId);
// if ( a != null ){
// obtainStyle(view, box, scope, a);
// a.recycle();
// }
// }
//
// onAfterCollect(view,context,attrs,box);
// insertSkinBox(view, box);
//
// // first refresh
// box.refreshSkin(mode, view, true);
// }
//
// private void obtainStyle(View view
// , ColorBox box
// , int scope
// , TypedArray a
// ){
//
// int n = a.getIndexCount();
// for (int i = 0; i < n; i++) {
// int attr = a.getIndex(i);
//
// // look for attr
// IOwlPaint paint = queryPaint(attr+scope);
// if ( paint == null) {
// Log.d(TAG, "Can't find paint of attr:" + attr + " scope:" + scope); continue; }
// Object[] values = paint.setup(view,a,attr);
// if ( values != null ) box.put(attr, scope, values);
// }
// }
//
// protected void onBeforeCollect(View view, Context context, AttributeSet attrs, ColorBox box){}
//
// protected void onAfterCollect(View view, Context context, AttributeSet attrs, ColorBox box){}
//
// @Override
// final public void onSkinChanged(int skin, View view) {
// ColorBox box = obtainSkinBox(view);
// if ( box != null ) box.refreshSkin(skin, view);
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/ColorBox.java
// public class ColorBox {
// private int mMode = -1;
// // may override the value, so we use SparseArray
// private SparseArray<Object[]> mBox;
// private ColorBox() {
// mBox = new SparseArray<>(4);
// }
//
// public void put(int attr, int scope, Object... objects){
// mBox.put(attr + scope, objects);
// }
//
// public void refreshSkin(int mode, View view, boolean force){
// if ( force ) mMode = -1;
// refreshSkin(mode,view);
// }
//
// public Object[] get(int attr, int scope){
// return mBox.get( attr + scope );
// }
//
// public void refreshSkin(int mode, View view){
// if ( mMode != mode ){
// int size = mBox.size();
// for (int i = 0; i < size; i++) {
// int attrWithScope = mBox.keyAt(i);
// Object[] res = mBox.valueAt(i);
// IOwlPaint paint = queryPaint(attrWithScope);
// if ( paint != null ) paint.draw(view, res[mode]);
// }
// }
// mMode = mode;
// }
//
// public int getMode() {
// return mMode;
// }
//
// public static ColorBox newInstance() {
// return new ColorBox();
// }
//
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/IOwlPaint.java
// public interface IOwlPaint {
// void draw(View view, Object value);
// Object[] setup(View view, TypedArray a, int attr);
// }
| import android.content.Context;
import android.content.res.TypedArray;
import android.support.annotation.NonNull;
import android.support.v7.widget.CardView;
import android.util.AttributeSet;
import android.view.View;
import com.asha.nightowl.R;
import com.asha.nightowllib.handler.annotations.OwlHandle;
import com.asha.nightowllib.handler.impls.AbsSkinHandler;
import com.asha.nightowllib.paint.ColorBox;
import com.asha.nightowllib.paint.IOwlPaint; | package com.asha.nightowl.custom;
/**
* Created by hzqiujiadi on 15/11/12.
* hzqiujiadi ashqalcn@gmail.com
*/
@OwlHandle(CardView.class)
public class CardViewHandler extends AbsSkinHandler implements OwlCustomTable.OwlCardView {
@Override | // Path: nightowllib/src/main/java/com/asha/nightowllib/handler/impls/AbsSkinHandler.java
// public abstract class AbsSkinHandler implements ISkinHandler {
// private final static String ANDROID_XML = "http://schemas.android.com/apk/res/android";
// private static final String TAG = "AbsSkinHandler";
//
// @Override
// public void collect(int mode, View view, Context context, AttributeSet attrs) {
// Log.d(TAG, String.format("collected %s %s %s", view, context, attrs));
// ColorBox box = ColorBox.newInstance();
// onBeforeCollect(view,context,attrs,box);
//
// final Resources.Theme theme = context.getTheme();
// int systemStyleResId = 0;
// Class clz = this.getClass();
//
// // SystemStyleable
// OwlSysStyleable systemStyleable = (OwlSysStyleable) clz.getAnnotation(OwlSysStyleable.class);
// if ( systemStyleable != null ){
// String value = systemStyleable.value();
// systemStyleResId = attrs.getAttributeResourceValue(ANDROID_XML, value, 0);
// }
//
// // OwlStyleable
// Field[] fields = clz.getFields();
// for ( Field field : fields ){
// OwlStyleable owlStyleable = field.getAnnotation(OwlStyleable.class);
// if ( owlStyleable == null ) continue;
//
// Class scopeClz = field.getDeclaringClass();
// OwlAttrScope owlAttrScope = (OwlAttrScope) scopeClz.getAnnotation(OwlAttrScope.class);
// if ( owlAttrScope == null ) continue;
//
// int scope = owlAttrScope.value();
// int[] styleableResId = getStaticFieldIntArraySafely(field);
// if ( styleableResId == null ) continue;
//
// TypedArray a = theme.obtainStyledAttributes(attrs, styleableResId, 0, systemStyleResId);
// if ( a != null ){
// obtainStyle(view, box, scope, a);
// a.recycle();
// }
// }
//
// onAfterCollect(view,context,attrs,box);
// insertSkinBox(view, box);
//
// // first refresh
// box.refreshSkin(mode, view, true);
// }
//
// private void obtainStyle(View view
// , ColorBox box
// , int scope
// , TypedArray a
// ){
//
// int n = a.getIndexCount();
// for (int i = 0; i < n; i++) {
// int attr = a.getIndex(i);
//
// // look for attr
// IOwlPaint paint = queryPaint(attr+scope);
// if ( paint == null) {
// Log.d(TAG, "Can't find paint of attr:" + attr + " scope:" + scope); continue; }
// Object[] values = paint.setup(view,a,attr);
// if ( values != null ) box.put(attr, scope, values);
// }
// }
//
// protected void onBeforeCollect(View view, Context context, AttributeSet attrs, ColorBox box){}
//
// protected void onAfterCollect(View view, Context context, AttributeSet attrs, ColorBox box){}
//
// @Override
// final public void onSkinChanged(int skin, View view) {
// ColorBox box = obtainSkinBox(view);
// if ( box != null ) box.refreshSkin(skin, view);
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/ColorBox.java
// public class ColorBox {
// private int mMode = -1;
// // may override the value, so we use SparseArray
// private SparseArray<Object[]> mBox;
// private ColorBox() {
// mBox = new SparseArray<>(4);
// }
//
// public void put(int attr, int scope, Object... objects){
// mBox.put(attr + scope, objects);
// }
//
// public void refreshSkin(int mode, View view, boolean force){
// if ( force ) mMode = -1;
// refreshSkin(mode,view);
// }
//
// public Object[] get(int attr, int scope){
// return mBox.get( attr + scope );
// }
//
// public void refreshSkin(int mode, View view){
// if ( mMode != mode ){
// int size = mBox.size();
// for (int i = 0; i < size; i++) {
// int attrWithScope = mBox.keyAt(i);
// Object[] res = mBox.valueAt(i);
// IOwlPaint paint = queryPaint(attrWithScope);
// if ( paint != null ) paint.draw(view, res[mode]);
// }
// }
// mMode = mode;
// }
//
// public int getMode() {
// return mMode;
// }
//
// public static ColorBox newInstance() {
// return new ColorBox();
// }
//
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/IOwlPaint.java
// public interface IOwlPaint {
// void draw(View view, Object value);
// Object[] setup(View view, TypedArray a, int attr);
// }
// Path: app/src/main/java/com/asha/nightowl/custom/CardViewHandler.java
import android.content.Context;
import android.content.res.TypedArray;
import android.support.annotation.NonNull;
import android.support.v7.widget.CardView;
import android.util.AttributeSet;
import android.view.View;
import com.asha.nightowl.R;
import com.asha.nightowllib.handler.annotations.OwlHandle;
import com.asha.nightowllib.handler.impls.AbsSkinHandler;
import com.asha.nightowllib.paint.ColorBox;
import com.asha.nightowllib.paint.IOwlPaint;
package com.asha.nightowl.custom;
/**
* Created by hzqiujiadi on 15/11/12.
* hzqiujiadi ashqalcn@gmail.com
*/
@OwlHandle(CardView.class)
public class CardViewHandler extends AbsSkinHandler implements OwlCustomTable.OwlCardView {
@Override | protected void onAfterCollect(View view, Context context, AttributeSet attrs, ColorBox box) { |
ashqal/NightOwl | nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java | // Path: nightowllib/src/main/java/com/asha/nightowllib/handler/ISkinHandler.java
// public interface ISkinHandler {
// void collect(int mode, View view, Context context, AttributeSet attrs);
// void onSkinChanged(int skin, View view);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/observer/OwlViewContext.java
// public class OwlViewContext {
// private int mLastMode = -1;
// private SparseArray<IOwlObserverWithId> observers;
// public OwlViewContext() {
// observers = new SparseArray<>();
// }
//
// public void registerObserver( IOwlObserverWithId owlObserver ){
// observers.put(owlObserver.getObserverId(), owlObserver);
// }
//
// public void unregisterObserver( IOwlObserverWithId owlObserver ){
// observers.delete(owlObserver.getObserverId());
// }
//
// public void notifyObserver(int mode, Activity activity){
// if ( mode == mLastMode ) return;
// mLastMode = mode;
// int size = observers.size();
// for (int i = 0; i < size; i++) {
// IOwlObserverWithId owlObserver = observers.valueAt(i);
// owlObserver.onSkinChange(mode, activity);
// }
// }
//
// public void setupWithCurrentActivity(Activity activity){
// Resources.Theme theme = activity.getTheme();
// TypedArray a = theme.obtainStyledAttributes(R.styleable.NightOwl_Theme);
// if (a != null) {
// if ( !checkBeforeLollipop() ){
// if ( a.hasValue(R.styleable.NightOwl_Theme_night_navigationBarColor) )
// registerObserver(new NavBarObserver(activity, a, R.styleable.NightOwl_Theme_night_navigationBarColor));
// if ( a.hasValue(R.styleable.NightOwl_Theme_night_statusBarColor) )
// registerObserver(new StatusBarObserver(activity, a, R.styleable.NightOwl_Theme_night_statusBarColor));
// }
//
// if ( a.hasValue(R.styleable.NightOwl_Theme_night_additionThemeDay)
// && a.hasValue(R.styleable.NightOwl_Theme_night_additionThemeNight) ){
// int themeDay = a.getResourceId(R.styleable.NightOwl_Theme_night_additionThemeDay,0 );
// int themeNight = a.getResourceId(R.styleable.NightOwl_Theme_night_additionThemeNight,0 );
// registerObserver(new AdditionThemeObserver(themeDay,themeNight));
// }
// a.recycle();
// }
// }
//
// public boolean needSync( int target ){
// return mLastMode != target;
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/ColorBox.java
// public class ColorBox {
// private int mMode = -1;
// // may override the value, so we use SparseArray
// private SparseArray<Object[]> mBox;
// private ColorBox() {
// mBox = new SparseArray<>(4);
// }
//
// public void put(int attr, int scope, Object... objects){
// mBox.put(attr + scope, objects);
// }
//
// public void refreshSkin(int mode, View view, boolean force){
// if ( force ) mMode = -1;
// refreshSkin(mode,view);
// }
//
// public Object[] get(int attr, int scope){
// return mBox.get( attr + scope );
// }
//
// public void refreshSkin(int mode, View view){
// if ( mMode != mode ){
// int size = mBox.size();
// for (int i = 0; i < size; i++) {
// int attrWithScope = mBox.keyAt(i);
// Object[] res = mBox.valueAt(i);
// IOwlPaint paint = queryPaint(attrWithScope);
// if ( paint != null ) paint.draw(view, res[mode]);
// }
// }
// mMode = mode;
// }
//
// public int getMode() {
// return mMode;
// }
//
// public static ColorBox newInstance() {
// return new ColorBox();
// }
//
// }
| import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import com.asha.nightowllib.handler.ISkinHandler;
import com.asha.nightowllib.observer.OwlViewContext;
import com.asha.nightowllib.paint.ColorBox;
import java.lang.reflect.Field; | package com.asha.nightowllib;
/**
* Created by hzqiujiadi on 15/11/5.
* hzqiujiadi ashqalcn@gmail.com
*/
public class NightOwlUtil {
public static final int NIGHT_OWL_VIEW_TAG = (2 << 24) | (1 << 23);
private static final String TAG = "NightOwlUtil";
private static final Boolean EMPTY_TAG = true;
public static void checkNonNull(Object obj,String msg){
if ( obj == null ) throw new NullPointerException(msg);
}
| // Path: nightowllib/src/main/java/com/asha/nightowllib/handler/ISkinHandler.java
// public interface ISkinHandler {
// void collect(int mode, View view, Context context, AttributeSet attrs);
// void onSkinChanged(int skin, View view);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/observer/OwlViewContext.java
// public class OwlViewContext {
// private int mLastMode = -1;
// private SparseArray<IOwlObserverWithId> observers;
// public OwlViewContext() {
// observers = new SparseArray<>();
// }
//
// public void registerObserver( IOwlObserverWithId owlObserver ){
// observers.put(owlObserver.getObserverId(), owlObserver);
// }
//
// public void unregisterObserver( IOwlObserverWithId owlObserver ){
// observers.delete(owlObserver.getObserverId());
// }
//
// public void notifyObserver(int mode, Activity activity){
// if ( mode == mLastMode ) return;
// mLastMode = mode;
// int size = observers.size();
// for (int i = 0; i < size; i++) {
// IOwlObserverWithId owlObserver = observers.valueAt(i);
// owlObserver.onSkinChange(mode, activity);
// }
// }
//
// public void setupWithCurrentActivity(Activity activity){
// Resources.Theme theme = activity.getTheme();
// TypedArray a = theme.obtainStyledAttributes(R.styleable.NightOwl_Theme);
// if (a != null) {
// if ( !checkBeforeLollipop() ){
// if ( a.hasValue(R.styleable.NightOwl_Theme_night_navigationBarColor) )
// registerObserver(new NavBarObserver(activity, a, R.styleable.NightOwl_Theme_night_navigationBarColor));
// if ( a.hasValue(R.styleable.NightOwl_Theme_night_statusBarColor) )
// registerObserver(new StatusBarObserver(activity, a, R.styleable.NightOwl_Theme_night_statusBarColor));
// }
//
// if ( a.hasValue(R.styleable.NightOwl_Theme_night_additionThemeDay)
// && a.hasValue(R.styleable.NightOwl_Theme_night_additionThemeNight) ){
// int themeDay = a.getResourceId(R.styleable.NightOwl_Theme_night_additionThemeDay,0 );
// int themeNight = a.getResourceId(R.styleable.NightOwl_Theme_night_additionThemeNight,0 );
// registerObserver(new AdditionThemeObserver(themeDay,themeNight));
// }
// a.recycle();
// }
// }
//
// public boolean needSync( int target ){
// return mLastMode != target;
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/ColorBox.java
// public class ColorBox {
// private int mMode = -1;
// // may override the value, so we use SparseArray
// private SparseArray<Object[]> mBox;
// private ColorBox() {
// mBox = new SparseArray<>(4);
// }
//
// public void put(int attr, int scope, Object... objects){
// mBox.put(attr + scope, objects);
// }
//
// public void refreshSkin(int mode, View view, boolean force){
// if ( force ) mMode = -1;
// refreshSkin(mode,view);
// }
//
// public Object[] get(int attr, int scope){
// return mBox.get( attr + scope );
// }
//
// public void refreshSkin(int mode, View view){
// if ( mMode != mode ){
// int size = mBox.size();
// for (int i = 0; i < size; i++) {
// int attrWithScope = mBox.keyAt(i);
// Object[] res = mBox.valueAt(i);
// IOwlPaint paint = queryPaint(attrWithScope);
// if ( paint != null ) paint.draw(view, res[mode]);
// }
// }
// mMode = mode;
// }
//
// public int getMode() {
// return mMode;
// }
//
// public static ColorBox newInstance() {
// return new ColorBox();
// }
//
// }
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import com.asha.nightowllib.handler.ISkinHandler;
import com.asha.nightowllib.observer.OwlViewContext;
import com.asha.nightowllib.paint.ColorBox;
import java.lang.reflect.Field;
package com.asha.nightowllib;
/**
* Created by hzqiujiadi on 15/11/5.
* hzqiujiadi ashqalcn@gmail.com
*/
public class NightOwlUtil {
public static final int NIGHT_OWL_VIEW_TAG = (2 << 24) | (1 << 23);
private static final String TAG = "NightOwlUtil";
private static final Boolean EMPTY_TAG = true;
public static void checkNonNull(Object obj,String msg){
if ( obj == null ) throw new NullPointerException(msg);
}
| public static boolean checkHandler(ISkinHandler handler,View view){ |
ashqal/NightOwl | nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java | // Path: nightowllib/src/main/java/com/asha/nightowllib/handler/ISkinHandler.java
// public interface ISkinHandler {
// void collect(int mode, View view, Context context, AttributeSet attrs);
// void onSkinChanged(int skin, View view);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/observer/OwlViewContext.java
// public class OwlViewContext {
// private int mLastMode = -1;
// private SparseArray<IOwlObserverWithId> observers;
// public OwlViewContext() {
// observers = new SparseArray<>();
// }
//
// public void registerObserver( IOwlObserverWithId owlObserver ){
// observers.put(owlObserver.getObserverId(), owlObserver);
// }
//
// public void unregisterObserver( IOwlObserverWithId owlObserver ){
// observers.delete(owlObserver.getObserverId());
// }
//
// public void notifyObserver(int mode, Activity activity){
// if ( mode == mLastMode ) return;
// mLastMode = mode;
// int size = observers.size();
// for (int i = 0; i < size; i++) {
// IOwlObserverWithId owlObserver = observers.valueAt(i);
// owlObserver.onSkinChange(mode, activity);
// }
// }
//
// public void setupWithCurrentActivity(Activity activity){
// Resources.Theme theme = activity.getTheme();
// TypedArray a = theme.obtainStyledAttributes(R.styleable.NightOwl_Theme);
// if (a != null) {
// if ( !checkBeforeLollipop() ){
// if ( a.hasValue(R.styleable.NightOwl_Theme_night_navigationBarColor) )
// registerObserver(new NavBarObserver(activity, a, R.styleable.NightOwl_Theme_night_navigationBarColor));
// if ( a.hasValue(R.styleable.NightOwl_Theme_night_statusBarColor) )
// registerObserver(new StatusBarObserver(activity, a, R.styleable.NightOwl_Theme_night_statusBarColor));
// }
//
// if ( a.hasValue(R.styleable.NightOwl_Theme_night_additionThemeDay)
// && a.hasValue(R.styleable.NightOwl_Theme_night_additionThemeNight) ){
// int themeDay = a.getResourceId(R.styleable.NightOwl_Theme_night_additionThemeDay,0 );
// int themeNight = a.getResourceId(R.styleable.NightOwl_Theme_night_additionThemeNight,0 );
// registerObserver(new AdditionThemeObserver(themeDay,themeNight));
// }
// a.recycle();
// }
// }
//
// public boolean needSync( int target ){
// return mLastMode != target;
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/ColorBox.java
// public class ColorBox {
// private int mMode = -1;
// // may override the value, so we use SparseArray
// private SparseArray<Object[]> mBox;
// private ColorBox() {
// mBox = new SparseArray<>(4);
// }
//
// public void put(int attr, int scope, Object... objects){
// mBox.put(attr + scope, objects);
// }
//
// public void refreshSkin(int mode, View view, boolean force){
// if ( force ) mMode = -1;
// refreshSkin(mode,view);
// }
//
// public Object[] get(int attr, int scope){
// return mBox.get( attr + scope );
// }
//
// public void refreshSkin(int mode, View view){
// if ( mMode != mode ){
// int size = mBox.size();
// for (int i = 0; i < size; i++) {
// int attrWithScope = mBox.keyAt(i);
// Object[] res = mBox.valueAt(i);
// IOwlPaint paint = queryPaint(attrWithScope);
// if ( paint != null ) paint.draw(view, res[mode]);
// }
// }
// mMode = mode;
// }
//
// public int getMode() {
// return mMode;
// }
//
// public static ColorBox newInstance() {
// return new ColorBox();
// }
//
// }
| import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import com.asha.nightowllib.handler.ISkinHandler;
import com.asha.nightowllib.observer.OwlViewContext;
import com.asha.nightowllib.paint.ColorBox;
import java.lang.reflect.Field; | package com.asha.nightowllib;
/**
* Created by hzqiujiadi on 15/11/5.
* hzqiujiadi ashqalcn@gmail.com
*/
public class NightOwlUtil {
public static final int NIGHT_OWL_VIEW_TAG = (2 << 24) | (1 << 23);
private static final String TAG = "NightOwlUtil";
private static final Boolean EMPTY_TAG = true;
public static void checkNonNull(Object obj,String msg){
if ( obj == null ) throw new NullPointerException(msg);
}
public static boolean checkHandler(ISkinHandler handler,View view){
if ( handler == null ){
Log.e(TAG, "Can't find handler of clz:" + view.getClass().getName());
return false;
}
return true;
}
public static boolean checkViewCollected(View view){
return view.getTag( NIGHT_OWL_VIEW_TAG ) != null;
}
public static boolean checkBeforeLollipop(){
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) return true;
else return false;
}
| // Path: nightowllib/src/main/java/com/asha/nightowllib/handler/ISkinHandler.java
// public interface ISkinHandler {
// void collect(int mode, View view, Context context, AttributeSet attrs);
// void onSkinChanged(int skin, View view);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/observer/OwlViewContext.java
// public class OwlViewContext {
// private int mLastMode = -1;
// private SparseArray<IOwlObserverWithId> observers;
// public OwlViewContext() {
// observers = new SparseArray<>();
// }
//
// public void registerObserver( IOwlObserverWithId owlObserver ){
// observers.put(owlObserver.getObserverId(), owlObserver);
// }
//
// public void unregisterObserver( IOwlObserverWithId owlObserver ){
// observers.delete(owlObserver.getObserverId());
// }
//
// public void notifyObserver(int mode, Activity activity){
// if ( mode == mLastMode ) return;
// mLastMode = mode;
// int size = observers.size();
// for (int i = 0; i < size; i++) {
// IOwlObserverWithId owlObserver = observers.valueAt(i);
// owlObserver.onSkinChange(mode, activity);
// }
// }
//
// public void setupWithCurrentActivity(Activity activity){
// Resources.Theme theme = activity.getTheme();
// TypedArray a = theme.obtainStyledAttributes(R.styleable.NightOwl_Theme);
// if (a != null) {
// if ( !checkBeforeLollipop() ){
// if ( a.hasValue(R.styleable.NightOwl_Theme_night_navigationBarColor) )
// registerObserver(new NavBarObserver(activity, a, R.styleable.NightOwl_Theme_night_navigationBarColor));
// if ( a.hasValue(R.styleable.NightOwl_Theme_night_statusBarColor) )
// registerObserver(new StatusBarObserver(activity, a, R.styleable.NightOwl_Theme_night_statusBarColor));
// }
//
// if ( a.hasValue(R.styleable.NightOwl_Theme_night_additionThemeDay)
// && a.hasValue(R.styleable.NightOwl_Theme_night_additionThemeNight) ){
// int themeDay = a.getResourceId(R.styleable.NightOwl_Theme_night_additionThemeDay,0 );
// int themeNight = a.getResourceId(R.styleable.NightOwl_Theme_night_additionThemeNight,0 );
// registerObserver(new AdditionThemeObserver(themeDay,themeNight));
// }
// a.recycle();
// }
// }
//
// public boolean needSync( int target ){
// return mLastMode != target;
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/ColorBox.java
// public class ColorBox {
// private int mMode = -1;
// // may override the value, so we use SparseArray
// private SparseArray<Object[]> mBox;
// private ColorBox() {
// mBox = new SparseArray<>(4);
// }
//
// public void put(int attr, int scope, Object... objects){
// mBox.put(attr + scope, objects);
// }
//
// public void refreshSkin(int mode, View view, boolean force){
// if ( force ) mMode = -1;
// refreshSkin(mode,view);
// }
//
// public Object[] get(int attr, int scope){
// return mBox.get( attr + scope );
// }
//
// public void refreshSkin(int mode, View view){
// if ( mMode != mode ){
// int size = mBox.size();
// for (int i = 0; i < size; i++) {
// int attrWithScope = mBox.keyAt(i);
// Object[] res = mBox.valueAt(i);
// IOwlPaint paint = queryPaint(attrWithScope);
// if ( paint != null ) paint.draw(view, res[mode]);
// }
// }
// mMode = mode;
// }
//
// public int getMode() {
// return mMode;
// }
//
// public static ColorBox newInstance() {
// return new ColorBox();
// }
//
// }
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import com.asha.nightowllib.handler.ISkinHandler;
import com.asha.nightowllib.observer.OwlViewContext;
import com.asha.nightowllib.paint.ColorBox;
import java.lang.reflect.Field;
package com.asha.nightowllib;
/**
* Created by hzqiujiadi on 15/11/5.
* hzqiujiadi ashqalcn@gmail.com
*/
public class NightOwlUtil {
public static final int NIGHT_OWL_VIEW_TAG = (2 << 24) | (1 << 23);
private static final String TAG = "NightOwlUtil";
private static final Boolean EMPTY_TAG = true;
public static void checkNonNull(Object obj,String msg){
if ( obj == null ) throw new NullPointerException(msg);
}
public static boolean checkHandler(ISkinHandler handler,View view){
if ( handler == null ){
Log.e(TAG, "Can't find handler of clz:" + view.getClass().getName());
return false;
}
return true;
}
public static boolean checkViewCollected(View view){
return view.getTag( NIGHT_OWL_VIEW_TAG ) != null;
}
public static boolean checkBeforeLollipop(){
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) return true;
else return false;
}
| public static void insertSkinBox(View view, ColorBox box){ |
ashqal/NightOwl | nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java | // Path: nightowllib/src/main/java/com/asha/nightowllib/handler/ISkinHandler.java
// public interface ISkinHandler {
// void collect(int mode, View view, Context context, AttributeSet attrs);
// void onSkinChanged(int skin, View view);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/observer/OwlViewContext.java
// public class OwlViewContext {
// private int mLastMode = -1;
// private SparseArray<IOwlObserverWithId> observers;
// public OwlViewContext() {
// observers = new SparseArray<>();
// }
//
// public void registerObserver( IOwlObserverWithId owlObserver ){
// observers.put(owlObserver.getObserverId(), owlObserver);
// }
//
// public void unregisterObserver( IOwlObserverWithId owlObserver ){
// observers.delete(owlObserver.getObserverId());
// }
//
// public void notifyObserver(int mode, Activity activity){
// if ( mode == mLastMode ) return;
// mLastMode = mode;
// int size = observers.size();
// for (int i = 0; i < size; i++) {
// IOwlObserverWithId owlObserver = observers.valueAt(i);
// owlObserver.onSkinChange(mode, activity);
// }
// }
//
// public void setupWithCurrentActivity(Activity activity){
// Resources.Theme theme = activity.getTheme();
// TypedArray a = theme.obtainStyledAttributes(R.styleable.NightOwl_Theme);
// if (a != null) {
// if ( !checkBeforeLollipop() ){
// if ( a.hasValue(R.styleable.NightOwl_Theme_night_navigationBarColor) )
// registerObserver(new NavBarObserver(activity, a, R.styleable.NightOwl_Theme_night_navigationBarColor));
// if ( a.hasValue(R.styleable.NightOwl_Theme_night_statusBarColor) )
// registerObserver(new StatusBarObserver(activity, a, R.styleable.NightOwl_Theme_night_statusBarColor));
// }
//
// if ( a.hasValue(R.styleable.NightOwl_Theme_night_additionThemeDay)
// && a.hasValue(R.styleable.NightOwl_Theme_night_additionThemeNight) ){
// int themeDay = a.getResourceId(R.styleable.NightOwl_Theme_night_additionThemeDay,0 );
// int themeNight = a.getResourceId(R.styleable.NightOwl_Theme_night_additionThemeNight,0 );
// registerObserver(new AdditionThemeObserver(themeDay,themeNight));
// }
// a.recycle();
// }
// }
//
// public boolean needSync( int target ){
// return mLastMode != target;
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/ColorBox.java
// public class ColorBox {
// private int mMode = -1;
// // may override the value, so we use SparseArray
// private SparseArray<Object[]> mBox;
// private ColorBox() {
// mBox = new SparseArray<>(4);
// }
//
// public void put(int attr, int scope, Object... objects){
// mBox.put(attr + scope, objects);
// }
//
// public void refreshSkin(int mode, View view, boolean force){
// if ( force ) mMode = -1;
// refreshSkin(mode,view);
// }
//
// public Object[] get(int attr, int scope){
// return mBox.get( attr + scope );
// }
//
// public void refreshSkin(int mode, View view){
// if ( mMode != mode ){
// int size = mBox.size();
// for (int i = 0; i < size; i++) {
// int attrWithScope = mBox.keyAt(i);
// Object[] res = mBox.valueAt(i);
// IOwlPaint paint = queryPaint(attrWithScope);
// if ( paint != null ) paint.draw(view, res[mode]);
// }
// }
// mMode = mode;
// }
//
// public int getMode() {
// return mMode;
// }
//
// public static ColorBox newInstance() {
// return new ColorBox();
// }
//
// }
| import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import com.asha.nightowllib.handler.ISkinHandler;
import com.asha.nightowllib.observer.OwlViewContext;
import com.asha.nightowllib.paint.ColorBox;
import java.lang.reflect.Field; | return view.getTag( NIGHT_OWL_VIEW_TAG ) != null;
}
public static boolean checkBeforeLollipop(){
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) return true;
else return false;
}
public static void insertSkinBox(View view, ColorBox box){
view.setTag(NIGHT_OWL_VIEW_TAG, box);
}
public static void insertEmptyTag(View view){
view.setTag(NIGHT_OWL_VIEW_TAG, EMPTY_TAG);
}
public static ColorBox obtainSkinBox(View view){
Object box = view.getTag(NIGHT_OWL_VIEW_TAG);
checkNonNull(box,"wtf, it can't be null.");
if ( box instanceof ColorBox ){
return (ColorBox) box;
} else if ( box.equals(EMPTY_TAG) ) {
Log.d(TAG, "EMPTY_TAG...");
return null;
} else {
Log.e(TAG, "wtf, NIGHT_OWL_VIEW_TAG had been used by someone else.");
}
return null;
}
| // Path: nightowllib/src/main/java/com/asha/nightowllib/handler/ISkinHandler.java
// public interface ISkinHandler {
// void collect(int mode, View view, Context context, AttributeSet attrs);
// void onSkinChanged(int skin, View view);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/observer/OwlViewContext.java
// public class OwlViewContext {
// private int mLastMode = -1;
// private SparseArray<IOwlObserverWithId> observers;
// public OwlViewContext() {
// observers = new SparseArray<>();
// }
//
// public void registerObserver( IOwlObserverWithId owlObserver ){
// observers.put(owlObserver.getObserverId(), owlObserver);
// }
//
// public void unregisterObserver( IOwlObserverWithId owlObserver ){
// observers.delete(owlObserver.getObserverId());
// }
//
// public void notifyObserver(int mode, Activity activity){
// if ( mode == mLastMode ) return;
// mLastMode = mode;
// int size = observers.size();
// for (int i = 0; i < size; i++) {
// IOwlObserverWithId owlObserver = observers.valueAt(i);
// owlObserver.onSkinChange(mode, activity);
// }
// }
//
// public void setupWithCurrentActivity(Activity activity){
// Resources.Theme theme = activity.getTheme();
// TypedArray a = theme.obtainStyledAttributes(R.styleable.NightOwl_Theme);
// if (a != null) {
// if ( !checkBeforeLollipop() ){
// if ( a.hasValue(R.styleable.NightOwl_Theme_night_navigationBarColor) )
// registerObserver(new NavBarObserver(activity, a, R.styleable.NightOwl_Theme_night_navigationBarColor));
// if ( a.hasValue(R.styleable.NightOwl_Theme_night_statusBarColor) )
// registerObserver(new StatusBarObserver(activity, a, R.styleable.NightOwl_Theme_night_statusBarColor));
// }
//
// if ( a.hasValue(R.styleable.NightOwl_Theme_night_additionThemeDay)
// && a.hasValue(R.styleable.NightOwl_Theme_night_additionThemeNight) ){
// int themeDay = a.getResourceId(R.styleable.NightOwl_Theme_night_additionThemeDay,0 );
// int themeNight = a.getResourceId(R.styleable.NightOwl_Theme_night_additionThemeNight,0 );
// registerObserver(new AdditionThemeObserver(themeDay,themeNight));
// }
// a.recycle();
// }
// }
//
// public boolean needSync( int target ){
// return mLastMode != target;
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/ColorBox.java
// public class ColorBox {
// private int mMode = -1;
// // may override the value, so we use SparseArray
// private SparseArray<Object[]> mBox;
// private ColorBox() {
// mBox = new SparseArray<>(4);
// }
//
// public void put(int attr, int scope, Object... objects){
// mBox.put(attr + scope, objects);
// }
//
// public void refreshSkin(int mode, View view, boolean force){
// if ( force ) mMode = -1;
// refreshSkin(mode,view);
// }
//
// public Object[] get(int attr, int scope){
// return mBox.get( attr + scope );
// }
//
// public void refreshSkin(int mode, View view){
// if ( mMode != mode ){
// int size = mBox.size();
// for (int i = 0; i < size; i++) {
// int attrWithScope = mBox.keyAt(i);
// Object[] res = mBox.valueAt(i);
// IOwlPaint paint = queryPaint(attrWithScope);
// if ( paint != null ) paint.draw(view, res[mode]);
// }
// }
// mMode = mode;
// }
//
// public int getMode() {
// return mMode;
// }
//
// public static ColorBox newInstance() {
// return new ColorBox();
// }
//
// }
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import com.asha.nightowllib.handler.ISkinHandler;
import com.asha.nightowllib.observer.OwlViewContext;
import com.asha.nightowllib.paint.ColorBox;
import java.lang.reflect.Field;
return view.getTag( NIGHT_OWL_VIEW_TAG ) != null;
}
public static boolean checkBeforeLollipop(){
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) return true;
else return false;
}
public static void insertSkinBox(View view, ColorBox box){
view.setTag(NIGHT_OWL_VIEW_TAG, box);
}
public static void insertEmptyTag(View view){
view.setTag(NIGHT_OWL_VIEW_TAG, EMPTY_TAG);
}
public static ColorBox obtainSkinBox(View view){
Object box = view.getTag(NIGHT_OWL_VIEW_TAG);
checkNonNull(box,"wtf, it can't be null.");
if ( box instanceof ColorBox ){
return (ColorBox) box;
} else if ( box.equals(EMPTY_TAG) ) {
Log.d(TAG, "EMPTY_TAG...");
return null;
} else {
Log.e(TAG, "wtf, NIGHT_OWL_VIEW_TAG had been used by someone else.");
}
return null;
}
| public static void insertViewContext(View view, OwlViewContext viewContext){ |
ashqal/NightOwl | app/src/main/java/com/asha/nightowl/DetailActivity.java | // Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwl.java
// public class NightOwl {
// private static final String TAG = "NightOwl";
// private static final String WINDOW_INFLATER = "mLayoutInflater";
// private static final String THEME_INFLATER = "mInflater";
// private static NightOwl sInstance;
// static {
// NightOwlTable.init();
// }
//
// private int mMode = 0;
// private IOwlObserver mOwlObserver;
// private NightOwl(){
// }
//
// public static void owlBeforeCreate(Activity activity){
// Window window = activity.getWindow();
// LayoutInflater layoutInflater = window.getLayoutInflater();
//
// // replace the inflater in window
// LayoutInflater injectLayoutInflater1 = Factory4InjectedInflater.newInstance(layoutInflater, activity);
// injectLayoutInflater(injectLayoutInflater1
// , activity.getWindow()
// , activity.getWindow().getClass()
// , WINDOW_INFLATER);
//
// // replace the inflater in current ContextThemeWrapper
// LayoutInflater injectLayoutInflater2 = injectLayoutInflater1.cloneInContext(activity);
// injectLayoutInflater(injectLayoutInflater2
// , activity
// , ContextThemeWrapper.class
// , THEME_INFLATER);
//
// // insert owlViewContext into root view.
// View v = activity.getWindow().getDecorView();
// OwlViewContext owlObservable = new OwlViewContext();
// insertViewContext(v, owlObservable);
//
// }
//
//
// public static void owlAfterCreate(Activity activity){
// View root = activity.getWindow().getDecorView();
// OwlViewContext viewContext = obtainViewContext(root);
// checkNonNull(viewContext, "OwlViewContext can not be null!");
//
// // setup some observer
// viewContext.setupWithCurrentActivity(activity);
//
// // init set
// viewContext.notifyObserver(sharedInstance().mMode, activity);
// }
//
// public static void owlResume( Activity activity ){
// NightOwl nightOwl = sharedInstance();
// int targetMode = nightOwl.mMode;
//
// owlDressUp(targetMode, activity);
// }
//
// public static void owlNewDress( Activity activity ) {
// int current = owlCurrentMode() + 1;
// current %= 2;
//
// owlDressUp(current, activity);
// }
//
// public static void owlRecyclerFix(View view){
// int mode = owlCurrentMode();
// innerRefreshSkin(mode, view);
// }
//
// private static void owlDressUp( int mode, Activity activity ){
// // View tree
// NightOwl owl = sharedInstance();
// View root = activity.getWindow().getDecorView();
// OwlViewContext viewContext = obtainViewContext(root);
// checkNonNull(viewContext, "OwlViewContext can not be null!");
//
// if ( viewContext.needSync(mode) ){
// // refresh skin
// innerRefreshSkin(mode, root);
//
// // OwlObserver
// viewContext.notifyObserver(mode, activity);
// }
//
// owl.mMode = mode;
// if ( owl.mOwlObserver != null ) owl.mOwlObserver.onSkinChange(mode,activity);
// }
//
// /**
// * Register a custom view which created by new instance directly.
// *
// * @param view instanceof IOwlObserver & View
// * NightOwl will trigger view.onSkinChange immediately.
// */
// public static void owlRegisterCustom(IOwlObserver view){
// if ( view instanceof View ) {
// View target = (View) view;
// insertEmptyTag(target);
// view.onSkinChange(owlCurrentMode(), null);
// } else {
// throw new IllegalArgumentException("owlRegisterCustom param must be a instance of View");
// }
// }
//
// public static void owlRegisterHandler(Class<? extends ISkinHandler> clz, Class paintTable){
// OwlHandlerManager.registerHandler(clz);
// OwlPaintManager.registerPaint(paintTable);
// }
//
// public static int owlCurrentMode(){
// return sharedInstance().mMode;
// }
//
// private static void innerRefreshSkin(int mode, View view ){
// // refresh current view
// if ( checkViewCollected(view) ){
// ColorBox box = obtainSkinBox(view);
// if ( box != null ) box.refreshSkin(mode, view);
// if ( view instanceof IOwlObserver ){
// ((IOwlObserver) view).onSkinChange(mode,null);
// }
// }
// // traversal view tree
// if ( view instanceof ViewGroup){
// ViewGroup vg = (ViewGroup) view;
// View sub;
// for (int i = 0; i < vg.getChildCount(); i++) {
// sub = vg.getChildAt(i);
// innerRefreshSkin(mode, sub);
// }
// }
// }
//
// private static NightOwl sharedInstance(){
// checkNonNull(sInstance,"You must create NightOwl in Application onCreate.");
// return sInstance;
// }
//
// public static Builder builder(){
// return new Builder();
// }
//
// public static class Builder {
// private int mode;
// private IOwlObserver owlObserver;
// public Builder defaultMode(int mode){
// this.mode = mode;
// return this;
// }
//
// /**
// * Subscribed by a owlObserver to know the skin change.
// *
// * @param owlObserver do some persistent working here
// * @return Builder
// */
// public Builder subscribedBy(IOwlObserver owlObserver){
// this.owlObserver = owlObserver;
// return this;
// }
// public NightOwl create(){
// if ( sInstance != null ) throw new RuntimeException("Do not create NightOwl again.");
// sInstance = new NightOwl();
// sInstance.mMode = mode;
// sInstance.mOwlObserver = owlObserver;
// return sInstance;
// }
// }
// }
| import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import com.asha.nightowllib.NightOwl; | package com.asha.nightowl;
public class DetailActivity extends AppCompatActivity {
public static void launch(Context context){
Intent i = new Intent(context,DetailActivity.class);
context.startActivity(i);
}
@Override
protected void onCreate(Bundle savedInstanceState) { | // Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwl.java
// public class NightOwl {
// private static final String TAG = "NightOwl";
// private static final String WINDOW_INFLATER = "mLayoutInflater";
// private static final String THEME_INFLATER = "mInflater";
// private static NightOwl sInstance;
// static {
// NightOwlTable.init();
// }
//
// private int mMode = 0;
// private IOwlObserver mOwlObserver;
// private NightOwl(){
// }
//
// public static void owlBeforeCreate(Activity activity){
// Window window = activity.getWindow();
// LayoutInflater layoutInflater = window.getLayoutInflater();
//
// // replace the inflater in window
// LayoutInflater injectLayoutInflater1 = Factory4InjectedInflater.newInstance(layoutInflater, activity);
// injectLayoutInflater(injectLayoutInflater1
// , activity.getWindow()
// , activity.getWindow().getClass()
// , WINDOW_INFLATER);
//
// // replace the inflater in current ContextThemeWrapper
// LayoutInflater injectLayoutInflater2 = injectLayoutInflater1.cloneInContext(activity);
// injectLayoutInflater(injectLayoutInflater2
// , activity
// , ContextThemeWrapper.class
// , THEME_INFLATER);
//
// // insert owlViewContext into root view.
// View v = activity.getWindow().getDecorView();
// OwlViewContext owlObservable = new OwlViewContext();
// insertViewContext(v, owlObservable);
//
// }
//
//
// public static void owlAfterCreate(Activity activity){
// View root = activity.getWindow().getDecorView();
// OwlViewContext viewContext = obtainViewContext(root);
// checkNonNull(viewContext, "OwlViewContext can not be null!");
//
// // setup some observer
// viewContext.setupWithCurrentActivity(activity);
//
// // init set
// viewContext.notifyObserver(sharedInstance().mMode, activity);
// }
//
// public static void owlResume( Activity activity ){
// NightOwl nightOwl = sharedInstance();
// int targetMode = nightOwl.mMode;
//
// owlDressUp(targetMode, activity);
// }
//
// public static void owlNewDress( Activity activity ) {
// int current = owlCurrentMode() + 1;
// current %= 2;
//
// owlDressUp(current, activity);
// }
//
// public static void owlRecyclerFix(View view){
// int mode = owlCurrentMode();
// innerRefreshSkin(mode, view);
// }
//
// private static void owlDressUp( int mode, Activity activity ){
// // View tree
// NightOwl owl = sharedInstance();
// View root = activity.getWindow().getDecorView();
// OwlViewContext viewContext = obtainViewContext(root);
// checkNonNull(viewContext, "OwlViewContext can not be null!");
//
// if ( viewContext.needSync(mode) ){
// // refresh skin
// innerRefreshSkin(mode, root);
//
// // OwlObserver
// viewContext.notifyObserver(mode, activity);
// }
//
// owl.mMode = mode;
// if ( owl.mOwlObserver != null ) owl.mOwlObserver.onSkinChange(mode,activity);
// }
//
// /**
// * Register a custom view which created by new instance directly.
// *
// * @param view instanceof IOwlObserver & View
// * NightOwl will trigger view.onSkinChange immediately.
// */
// public static void owlRegisterCustom(IOwlObserver view){
// if ( view instanceof View ) {
// View target = (View) view;
// insertEmptyTag(target);
// view.onSkinChange(owlCurrentMode(), null);
// } else {
// throw new IllegalArgumentException("owlRegisterCustom param must be a instance of View");
// }
// }
//
// public static void owlRegisterHandler(Class<? extends ISkinHandler> clz, Class paintTable){
// OwlHandlerManager.registerHandler(clz);
// OwlPaintManager.registerPaint(paintTable);
// }
//
// public static int owlCurrentMode(){
// return sharedInstance().mMode;
// }
//
// private static void innerRefreshSkin(int mode, View view ){
// // refresh current view
// if ( checkViewCollected(view) ){
// ColorBox box = obtainSkinBox(view);
// if ( box != null ) box.refreshSkin(mode, view);
// if ( view instanceof IOwlObserver ){
// ((IOwlObserver) view).onSkinChange(mode,null);
// }
// }
// // traversal view tree
// if ( view instanceof ViewGroup){
// ViewGroup vg = (ViewGroup) view;
// View sub;
// for (int i = 0; i < vg.getChildCount(); i++) {
// sub = vg.getChildAt(i);
// innerRefreshSkin(mode, sub);
// }
// }
// }
//
// private static NightOwl sharedInstance(){
// checkNonNull(sInstance,"You must create NightOwl in Application onCreate.");
// return sInstance;
// }
//
// public static Builder builder(){
// return new Builder();
// }
//
// public static class Builder {
// private int mode;
// private IOwlObserver owlObserver;
// public Builder defaultMode(int mode){
// this.mode = mode;
// return this;
// }
//
// /**
// * Subscribed by a owlObserver to know the skin change.
// *
// * @param owlObserver do some persistent working here
// * @return Builder
// */
// public Builder subscribedBy(IOwlObserver owlObserver){
// this.owlObserver = owlObserver;
// return this;
// }
// public NightOwl create(){
// if ( sInstance != null ) throw new RuntimeException("Do not create NightOwl again.");
// sInstance = new NightOwl();
// sInstance.mMode = mode;
// sInstance.mOwlObserver = owlObserver;
// return sInstance;
// }
// }
// }
// Path: app/src/main/java/com/asha/nightowl/DetailActivity.java
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import com.asha.nightowllib.NightOwl;
package com.asha.nightowl;
public class DetailActivity extends AppCompatActivity {
public static void launch(Context context){
Intent i = new Intent(context,DetailActivity.class);
context.startActivity(i);
}
@Override
protected void onCreate(Bundle savedInstanceState) { | NightOwl.owlBeforeCreate(this); |
ashqal/NightOwl | app/src/main/java/com/asha/nightowl/fragments/ListViewFragment.java | // Path: app/src/main/java/com/asha/nightowl/DetailActivity.java
// public class DetailActivity extends AppCompatActivity {
//
// public static void launch(Context context){
// Intent i = new Intent(context,DetailActivity.class);
// context.startActivity(i);
// }
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// NightOwl.owlBeforeCreate(this);
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_detail);
// NightOwl.owlAfterCreate(this);
//
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
// if (getSupportActionBar() != null) getSupportActionBar().setDisplayShowHomeEnabled(true);
// }
//
// @Override
// protected void onResume() {
// super.onResume();
// NightOwl.owlResume(this);
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// switch (item.getItemId()){
// case android.R.id.home: this.finish(); return true;
// }
// return super.onOptionsItemSelected(item);
// }
// }
//
// Path: app/src/main/java/com/asha/nightowl/DemoUtil.java
// public static int fetchFakeImage(int positon){
//
// return FakeImage[positon % FakeImage.length];
// }
| import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import com.asha.nightowl.DetailActivity;
import com.asha.nightowl.R;
import static com.asha.nightowl.DemoUtil.fetchFakeImage; | package com.asha.nightowl.fragments;
/**
* Created by hzqiujiadi on 15/11/9.
* hzqiujiadi ashqalcn@gmail.com
*/
public class ListViewFragment extends Fragment {
public static ListViewFragment newInstance() {
Bundle args = new Bundle();
ListViewFragment fragment = new ListViewFragment();
fragment.setArguments(args);
return fragment;
}
public ListViewFragment() {
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
ListView listView = (ListView) view.findViewById(R.id.listview);
listView.setAdapter(new DemoAdapter());
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | // Path: app/src/main/java/com/asha/nightowl/DetailActivity.java
// public class DetailActivity extends AppCompatActivity {
//
// public static void launch(Context context){
// Intent i = new Intent(context,DetailActivity.class);
// context.startActivity(i);
// }
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// NightOwl.owlBeforeCreate(this);
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_detail);
// NightOwl.owlAfterCreate(this);
//
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
// if (getSupportActionBar() != null) getSupportActionBar().setDisplayShowHomeEnabled(true);
// }
//
// @Override
// protected void onResume() {
// super.onResume();
// NightOwl.owlResume(this);
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// switch (item.getItemId()){
// case android.R.id.home: this.finish(); return true;
// }
// return super.onOptionsItemSelected(item);
// }
// }
//
// Path: app/src/main/java/com/asha/nightowl/DemoUtil.java
// public static int fetchFakeImage(int positon){
//
// return FakeImage[positon % FakeImage.length];
// }
// Path: app/src/main/java/com/asha/nightowl/fragments/ListViewFragment.java
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import com.asha.nightowl.DetailActivity;
import com.asha.nightowl.R;
import static com.asha.nightowl.DemoUtil.fetchFakeImage;
package com.asha.nightowl.fragments;
/**
* Created by hzqiujiadi on 15/11/9.
* hzqiujiadi ashqalcn@gmail.com
*/
public class ListViewFragment extends Fragment {
public static ListViewFragment newInstance() {
Bundle args = new Bundle();
ListViewFragment fragment = new ListViewFragment();
fragment.setArguments(args);
return fragment;
}
public ListViewFragment() {
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
ListView listView = (ListView) view.findViewById(R.id.listview);
listView.setAdapter(new DemoAdapter());
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | DetailActivity.launch(view.getContext()); |
ashqal/NightOwl | app/src/main/java/com/asha/nightowl/fragments/ListViewFragment.java | // Path: app/src/main/java/com/asha/nightowl/DetailActivity.java
// public class DetailActivity extends AppCompatActivity {
//
// public static void launch(Context context){
// Intent i = new Intent(context,DetailActivity.class);
// context.startActivity(i);
// }
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// NightOwl.owlBeforeCreate(this);
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_detail);
// NightOwl.owlAfterCreate(this);
//
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
// if (getSupportActionBar() != null) getSupportActionBar().setDisplayShowHomeEnabled(true);
// }
//
// @Override
// protected void onResume() {
// super.onResume();
// NightOwl.owlResume(this);
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// switch (item.getItemId()){
// case android.R.id.home: this.finish(); return true;
// }
// return super.onOptionsItemSelected(item);
// }
// }
//
// Path: app/src/main/java/com/asha/nightowl/DemoUtil.java
// public static int fetchFakeImage(int positon){
//
// return FakeImage[positon % FakeImage.length];
// }
| import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import com.asha.nightowl.DetailActivity;
import com.asha.nightowl.R;
import static com.asha.nightowl.DemoUtil.fetchFakeImage; |
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if ( convertView == null ){
if ( mLayoutInflater == null )
mLayoutInflater = LayoutInflater.from(parent.getContext());
convertView = mLayoutInflater.inflate(R.layout.item_view1,parent,false);
}
VH vh = (VH) convertView.getTag();
if( vh == null ){
vh = new VH(convertView);
convertView.setTag(vh);
}
vh.bind(position);
return convertView;
}
}
public static class VH {
ImageView mImageView;
public VH(View mView) {
mImageView = (ImageView) mView.findViewById(R.id.image);
}
public void bind(int position){ | // Path: app/src/main/java/com/asha/nightowl/DetailActivity.java
// public class DetailActivity extends AppCompatActivity {
//
// public static void launch(Context context){
// Intent i = new Intent(context,DetailActivity.class);
// context.startActivity(i);
// }
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// NightOwl.owlBeforeCreate(this);
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_detail);
// NightOwl.owlAfterCreate(this);
//
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
// if (getSupportActionBar() != null) getSupportActionBar().setDisplayShowHomeEnabled(true);
// }
//
// @Override
// protected void onResume() {
// super.onResume();
// NightOwl.owlResume(this);
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// switch (item.getItemId()){
// case android.R.id.home: this.finish(); return true;
// }
// return super.onOptionsItemSelected(item);
// }
// }
//
// Path: app/src/main/java/com/asha/nightowl/DemoUtil.java
// public static int fetchFakeImage(int positon){
//
// return FakeImage[positon % FakeImage.length];
// }
// Path: app/src/main/java/com/asha/nightowl/fragments/ListViewFragment.java
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import com.asha.nightowl.DetailActivity;
import com.asha.nightowl.R;
import static com.asha.nightowl.DemoUtil.fetchFakeImage;
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if ( convertView == null ){
if ( mLayoutInflater == null )
mLayoutInflater = LayoutInflater.from(parent.getContext());
convertView = mLayoutInflater.inflate(R.layout.item_view1,parent,false);
}
VH vh = (VH) convertView.getTag();
if( vh == null ){
vh = new VH(convertView);
convertView.setTag(vh);
}
vh.bind(position);
return convertView;
}
}
public static class VH {
ImageView mImageView;
public VH(View mView) {
mImageView = (ImageView) mView.findViewById(R.id.image);
}
public void bind(int position){ | mImageView.setImageResource(fetchFakeImage(position)); |
ashqal/NightOwl | app/src/main/java/com/asha/nightowl/custom/CollapsingToolbarLayoutHandler.java | // Path: nightowllib/src/main/java/com/asha/nightowllib/handler/impls/AbsSkinHandler.java
// public abstract class AbsSkinHandler implements ISkinHandler {
// private final static String ANDROID_XML = "http://schemas.android.com/apk/res/android";
// private static final String TAG = "AbsSkinHandler";
//
// @Override
// public void collect(int mode, View view, Context context, AttributeSet attrs) {
// Log.d(TAG, String.format("collected %s %s %s", view, context, attrs));
// ColorBox box = ColorBox.newInstance();
// onBeforeCollect(view,context,attrs,box);
//
// final Resources.Theme theme = context.getTheme();
// int systemStyleResId = 0;
// Class clz = this.getClass();
//
// // SystemStyleable
// OwlSysStyleable systemStyleable = (OwlSysStyleable) clz.getAnnotation(OwlSysStyleable.class);
// if ( systemStyleable != null ){
// String value = systemStyleable.value();
// systemStyleResId = attrs.getAttributeResourceValue(ANDROID_XML, value, 0);
// }
//
// // OwlStyleable
// Field[] fields = clz.getFields();
// for ( Field field : fields ){
// OwlStyleable owlStyleable = field.getAnnotation(OwlStyleable.class);
// if ( owlStyleable == null ) continue;
//
// Class scopeClz = field.getDeclaringClass();
// OwlAttrScope owlAttrScope = (OwlAttrScope) scopeClz.getAnnotation(OwlAttrScope.class);
// if ( owlAttrScope == null ) continue;
//
// int scope = owlAttrScope.value();
// int[] styleableResId = getStaticFieldIntArraySafely(field);
// if ( styleableResId == null ) continue;
//
// TypedArray a = theme.obtainStyledAttributes(attrs, styleableResId, 0, systemStyleResId);
// if ( a != null ){
// obtainStyle(view, box, scope, a);
// a.recycle();
// }
// }
//
// onAfterCollect(view,context,attrs,box);
// insertSkinBox(view, box);
//
// // first refresh
// box.refreshSkin(mode, view, true);
// }
//
// private void obtainStyle(View view
// , ColorBox box
// , int scope
// , TypedArray a
// ){
//
// int n = a.getIndexCount();
// for (int i = 0; i < n; i++) {
// int attr = a.getIndex(i);
//
// // look for attr
// IOwlPaint paint = queryPaint(attr+scope);
// if ( paint == null) {
// Log.d(TAG, "Can't find paint of attr:" + attr + " scope:" + scope); continue; }
// Object[] values = paint.setup(view,a,attr);
// if ( values != null ) box.put(attr, scope, values);
// }
// }
//
// protected void onBeforeCollect(View view, Context context, AttributeSet attrs, ColorBox box){}
//
// protected void onAfterCollect(View view, Context context, AttributeSet attrs, ColorBox box){}
//
// @Override
// final public void onSkinChanged(int skin, View view) {
// ColorBox box = obtainSkinBox(view);
// if ( box != null ) box.refreshSkin(skin, view);
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/IOwlPaint.java
// public interface IOwlPaint {
// void draw(View view, Object value);
// Object[] setup(View view, TypedArray a, int attr);
// }
| import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.design.widget.CollapsingToolbarLayout;
import android.view.View;
import com.asha.nightowllib.handler.annotations.OwlHandle;
import com.asha.nightowllib.handler.impls.AbsSkinHandler;
import com.asha.nightowllib.paint.IOwlPaint; | package com.asha.nightowl.custom;
/**
* Created by hzqiujiadi on 15/11/11.
* hzqiujiadi ashqalcn@gmail.com
*/
@OwlHandle(CollapsingToolbarLayout.class)
public class CollapsingToolbarLayoutHandler extends AbsSkinHandler implements OwlCustomTable.OwlCollapsingToolbarLayout {
//NightOwl_CollapsingToolbarLayout_night_contentScrim
| // Path: nightowllib/src/main/java/com/asha/nightowllib/handler/impls/AbsSkinHandler.java
// public abstract class AbsSkinHandler implements ISkinHandler {
// private final static String ANDROID_XML = "http://schemas.android.com/apk/res/android";
// private static final String TAG = "AbsSkinHandler";
//
// @Override
// public void collect(int mode, View view, Context context, AttributeSet attrs) {
// Log.d(TAG, String.format("collected %s %s %s", view, context, attrs));
// ColorBox box = ColorBox.newInstance();
// onBeforeCollect(view,context,attrs,box);
//
// final Resources.Theme theme = context.getTheme();
// int systemStyleResId = 0;
// Class clz = this.getClass();
//
// // SystemStyleable
// OwlSysStyleable systemStyleable = (OwlSysStyleable) clz.getAnnotation(OwlSysStyleable.class);
// if ( systemStyleable != null ){
// String value = systemStyleable.value();
// systemStyleResId = attrs.getAttributeResourceValue(ANDROID_XML, value, 0);
// }
//
// // OwlStyleable
// Field[] fields = clz.getFields();
// for ( Field field : fields ){
// OwlStyleable owlStyleable = field.getAnnotation(OwlStyleable.class);
// if ( owlStyleable == null ) continue;
//
// Class scopeClz = field.getDeclaringClass();
// OwlAttrScope owlAttrScope = (OwlAttrScope) scopeClz.getAnnotation(OwlAttrScope.class);
// if ( owlAttrScope == null ) continue;
//
// int scope = owlAttrScope.value();
// int[] styleableResId = getStaticFieldIntArraySafely(field);
// if ( styleableResId == null ) continue;
//
// TypedArray a = theme.obtainStyledAttributes(attrs, styleableResId, 0, systemStyleResId);
// if ( a != null ){
// obtainStyle(view, box, scope, a);
// a.recycle();
// }
// }
//
// onAfterCollect(view,context,attrs,box);
// insertSkinBox(view, box);
//
// // first refresh
// box.refreshSkin(mode, view, true);
// }
//
// private void obtainStyle(View view
// , ColorBox box
// , int scope
// , TypedArray a
// ){
//
// int n = a.getIndexCount();
// for (int i = 0; i < n; i++) {
// int attr = a.getIndex(i);
//
// // look for attr
// IOwlPaint paint = queryPaint(attr+scope);
// if ( paint == null) {
// Log.d(TAG, "Can't find paint of attr:" + attr + " scope:" + scope); continue; }
// Object[] values = paint.setup(view,a,attr);
// if ( values != null ) box.put(attr, scope, values);
// }
// }
//
// protected void onBeforeCollect(View view, Context context, AttributeSet attrs, ColorBox box){}
//
// protected void onAfterCollect(View view, Context context, AttributeSet attrs, ColorBox box){}
//
// @Override
// final public void onSkinChanged(int skin, View view) {
// ColorBox box = obtainSkinBox(view);
// if ( box != null ) box.refreshSkin(skin, view);
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/IOwlPaint.java
// public interface IOwlPaint {
// void draw(View view, Object value);
// Object[] setup(View view, TypedArray a, int attr);
// }
// Path: app/src/main/java/com/asha/nightowl/custom/CollapsingToolbarLayoutHandler.java
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.design.widget.CollapsingToolbarLayout;
import android.view.View;
import com.asha.nightowllib.handler.annotations.OwlHandle;
import com.asha.nightowllib.handler.impls.AbsSkinHandler;
import com.asha.nightowllib.paint.IOwlPaint;
package com.asha.nightowl.custom;
/**
* Created by hzqiujiadi on 15/11/11.
* hzqiujiadi ashqalcn@gmail.com
*/
@OwlHandle(CollapsingToolbarLayout.class)
public class CollapsingToolbarLayoutHandler extends AbsSkinHandler implements OwlCustomTable.OwlCollapsingToolbarLayout {
//NightOwl_CollapsingToolbarLayout_night_contentScrim
| public static class ContentScrimPaint implements IOwlPaint{ |
ashqal/NightOwl | nightowllib/src/main/java/com/asha/nightowllib/handler/impls/AbsSkinHandler.java | // Path: nightowllib/src/main/java/com/asha/nightowllib/handler/ISkinHandler.java
// public interface ISkinHandler {
// void collect(int mode, View view, Context context, AttributeSet attrs);
// void onSkinChanged(int skin, View view);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/ColorBox.java
// public class ColorBox {
// private int mMode = -1;
// // may override the value, so we use SparseArray
// private SparseArray<Object[]> mBox;
// private ColorBox() {
// mBox = new SparseArray<>(4);
// }
//
// public void put(int attr, int scope, Object... objects){
// mBox.put(attr + scope, objects);
// }
//
// public void refreshSkin(int mode, View view, boolean force){
// if ( force ) mMode = -1;
// refreshSkin(mode,view);
// }
//
// public Object[] get(int attr, int scope){
// return mBox.get( attr + scope );
// }
//
// public void refreshSkin(int mode, View view){
// if ( mMode != mode ){
// int size = mBox.size();
// for (int i = 0; i < size; i++) {
// int attrWithScope = mBox.keyAt(i);
// Object[] res = mBox.valueAt(i);
// IOwlPaint paint = queryPaint(attrWithScope);
// if ( paint != null ) paint.draw(view, res[mode]);
// }
// }
// mMode = mode;
// }
//
// public int getMode() {
// return mMode;
// }
//
// public static ColorBox newInstance() {
// return new ColorBox();
// }
//
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/IOwlPaint.java
// public interface IOwlPaint {
// void draw(View view, Object value);
// Object[] setup(View view, TypedArray a, int attr);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static int[] getStaticFieldIntArraySafely(Field field){
// try {
// return (int[]) field.get(null);
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// return null;
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static void insertSkinBox(View view, ColorBox box){
// view.setTag(NIGHT_OWL_VIEW_TAG, box);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static ColorBox obtainSkinBox(View view){
// Object box = view.getTag(NIGHT_OWL_VIEW_TAG);
// checkNonNull(box,"wtf, it can't be null.");
// if ( box instanceof ColorBox ){
// return (ColorBox) box;
// } else if ( box.equals(EMPTY_TAG) ) {
// Log.d(TAG, "EMPTY_TAG...");
// return null;
// } else {
// Log.e(TAG, "wtf, NIGHT_OWL_VIEW_TAG had been used by someone else.");
// }
// return null;
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/OwlPaintManager.java
// public static IOwlPaint queryPaint(int attrWithScope){
// Class< ? extends IOwlPaint> clz = sPaints.get(attrWithScope);
// if ( clz == null ) return null;
// IOwlPaint instance = sPaintInstances.get(clz);
// if ( instance == null ){
// instance = newInstanceSafely(clz);
// sPaintInstances.put(clz,instance);
// }
// return instance;
// }
| import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import com.asha.nightowllib.handler.ISkinHandler;
import com.asha.nightowllib.handler.annotations.OwlAttrScope;
import com.asha.nightowllib.handler.annotations.OwlStyleable;
import com.asha.nightowllib.handler.annotations.OwlSysStyleable;
import com.asha.nightowllib.paint.ColorBox;
import com.asha.nightowllib.paint.IOwlPaint;
import java.lang.reflect.Field;
import static com.asha.nightowllib.NightOwlUtil.getStaticFieldIntArraySafely;
import static com.asha.nightowllib.NightOwlUtil.insertSkinBox;
import static com.asha.nightowllib.NightOwlUtil.obtainSkinBox;
import static com.asha.nightowllib.paint.OwlPaintManager.queryPaint; | package com.asha.nightowllib.handler.impls;
/**
* Created by hzqiujiadi on 15/11/6.
* hzqiujiadi ashqalcn@gmail.com
*/
public abstract class AbsSkinHandler implements ISkinHandler {
private final static String ANDROID_XML = "http://schemas.android.com/apk/res/android";
private static final String TAG = "AbsSkinHandler";
@Override
public void collect(int mode, View view, Context context, AttributeSet attrs) {
Log.d(TAG, String.format("collected %s %s %s", view, context, attrs)); | // Path: nightowllib/src/main/java/com/asha/nightowllib/handler/ISkinHandler.java
// public interface ISkinHandler {
// void collect(int mode, View view, Context context, AttributeSet attrs);
// void onSkinChanged(int skin, View view);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/ColorBox.java
// public class ColorBox {
// private int mMode = -1;
// // may override the value, so we use SparseArray
// private SparseArray<Object[]> mBox;
// private ColorBox() {
// mBox = new SparseArray<>(4);
// }
//
// public void put(int attr, int scope, Object... objects){
// mBox.put(attr + scope, objects);
// }
//
// public void refreshSkin(int mode, View view, boolean force){
// if ( force ) mMode = -1;
// refreshSkin(mode,view);
// }
//
// public Object[] get(int attr, int scope){
// return mBox.get( attr + scope );
// }
//
// public void refreshSkin(int mode, View view){
// if ( mMode != mode ){
// int size = mBox.size();
// for (int i = 0; i < size; i++) {
// int attrWithScope = mBox.keyAt(i);
// Object[] res = mBox.valueAt(i);
// IOwlPaint paint = queryPaint(attrWithScope);
// if ( paint != null ) paint.draw(view, res[mode]);
// }
// }
// mMode = mode;
// }
//
// public int getMode() {
// return mMode;
// }
//
// public static ColorBox newInstance() {
// return new ColorBox();
// }
//
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/IOwlPaint.java
// public interface IOwlPaint {
// void draw(View view, Object value);
// Object[] setup(View view, TypedArray a, int attr);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static int[] getStaticFieldIntArraySafely(Field field){
// try {
// return (int[]) field.get(null);
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// return null;
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static void insertSkinBox(View view, ColorBox box){
// view.setTag(NIGHT_OWL_VIEW_TAG, box);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static ColorBox obtainSkinBox(View view){
// Object box = view.getTag(NIGHT_OWL_VIEW_TAG);
// checkNonNull(box,"wtf, it can't be null.");
// if ( box instanceof ColorBox ){
// return (ColorBox) box;
// } else if ( box.equals(EMPTY_TAG) ) {
// Log.d(TAG, "EMPTY_TAG...");
// return null;
// } else {
// Log.e(TAG, "wtf, NIGHT_OWL_VIEW_TAG had been used by someone else.");
// }
// return null;
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/OwlPaintManager.java
// public static IOwlPaint queryPaint(int attrWithScope){
// Class< ? extends IOwlPaint> clz = sPaints.get(attrWithScope);
// if ( clz == null ) return null;
// IOwlPaint instance = sPaintInstances.get(clz);
// if ( instance == null ){
// instance = newInstanceSafely(clz);
// sPaintInstances.put(clz,instance);
// }
// return instance;
// }
// Path: nightowllib/src/main/java/com/asha/nightowllib/handler/impls/AbsSkinHandler.java
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import com.asha.nightowllib.handler.ISkinHandler;
import com.asha.nightowllib.handler.annotations.OwlAttrScope;
import com.asha.nightowllib.handler.annotations.OwlStyleable;
import com.asha.nightowllib.handler.annotations.OwlSysStyleable;
import com.asha.nightowllib.paint.ColorBox;
import com.asha.nightowllib.paint.IOwlPaint;
import java.lang.reflect.Field;
import static com.asha.nightowllib.NightOwlUtil.getStaticFieldIntArraySafely;
import static com.asha.nightowllib.NightOwlUtil.insertSkinBox;
import static com.asha.nightowllib.NightOwlUtil.obtainSkinBox;
import static com.asha.nightowllib.paint.OwlPaintManager.queryPaint;
package com.asha.nightowllib.handler.impls;
/**
* Created by hzqiujiadi on 15/11/6.
* hzqiujiadi ashqalcn@gmail.com
*/
public abstract class AbsSkinHandler implements ISkinHandler {
private final static String ANDROID_XML = "http://schemas.android.com/apk/res/android";
private static final String TAG = "AbsSkinHandler";
@Override
public void collect(int mode, View view, Context context, AttributeSet attrs) {
Log.d(TAG, String.format("collected %s %s %s", view, context, attrs)); | ColorBox box = ColorBox.newInstance(); |
ashqal/NightOwl | nightowllib/src/main/java/com/asha/nightowllib/handler/impls/AbsSkinHandler.java | // Path: nightowllib/src/main/java/com/asha/nightowllib/handler/ISkinHandler.java
// public interface ISkinHandler {
// void collect(int mode, View view, Context context, AttributeSet attrs);
// void onSkinChanged(int skin, View view);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/ColorBox.java
// public class ColorBox {
// private int mMode = -1;
// // may override the value, so we use SparseArray
// private SparseArray<Object[]> mBox;
// private ColorBox() {
// mBox = new SparseArray<>(4);
// }
//
// public void put(int attr, int scope, Object... objects){
// mBox.put(attr + scope, objects);
// }
//
// public void refreshSkin(int mode, View view, boolean force){
// if ( force ) mMode = -1;
// refreshSkin(mode,view);
// }
//
// public Object[] get(int attr, int scope){
// return mBox.get( attr + scope );
// }
//
// public void refreshSkin(int mode, View view){
// if ( mMode != mode ){
// int size = mBox.size();
// for (int i = 0; i < size; i++) {
// int attrWithScope = mBox.keyAt(i);
// Object[] res = mBox.valueAt(i);
// IOwlPaint paint = queryPaint(attrWithScope);
// if ( paint != null ) paint.draw(view, res[mode]);
// }
// }
// mMode = mode;
// }
//
// public int getMode() {
// return mMode;
// }
//
// public static ColorBox newInstance() {
// return new ColorBox();
// }
//
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/IOwlPaint.java
// public interface IOwlPaint {
// void draw(View view, Object value);
// Object[] setup(View view, TypedArray a, int attr);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static int[] getStaticFieldIntArraySafely(Field field){
// try {
// return (int[]) field.get(null);
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// return null;
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static void insertSkinBox(View view, ColorBox box){
// view.setTag(NIGHT_OWL_VIEW_TAG, box);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static ColorBox obtainSkinBox(View view){
// Object box = view.getTag(NIGHT_OWL_VIEW_TAG);
// checkNonNull(box,"wtf, it can't be null.");
// if ( box instanceof ColorBox ){
// return (ColorBox) box;
// } else if ( box.equals(EMPTY_TAG) ) {
// Log.d(TAG, "EMPTY_TAG...");
// return null;
// } else {
// Log.e(TAG, "wtf, NIGHT_OWL_VIEW_TAG had been used by someone else.");
// }
// return null;
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/OwlPaintManager.java
// public static IOwlPaint queryPaint(int attrWithScope){
// Class< ? extends IOwlPaint> clz = sPaints.get(attrWithScope);
// if ( clz == null ) return null;
// IOwlPaint instance = sPaintInstances.get(clz);
// if ( instance == null ){
// instance = newInstanceSafely(clz);
// sPaintInstances.put(clz,instance);
// }
// return instance;
// }
| import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import com.asha.nightowllib.handler.ISkinHandler;
import com.asha.nightowllib.handler.annotations.OwlAttrScope;
import com.asha.nightowllib.handler.annotations.OwlStyleable;
import com.asha.nightowllib.handler.annotations.OwlSysStyleable;
import com.asha.nightowllib.paint.ColorBox;
import com.asha.nightowllib.paint.IOwlPaint;
import java.lang.reflect.Field;
import static com.asha.nightowllib.NightOwlUtil.getStaticFieldIntArraySafely;
import static com.asha.nightowllib.NightOwlUtil.insertSkinBox;
import static com.asha.nightowllib.NightOwlUtil.obtainSkinBox;
import static com.asha.nightowllib.paint.OwlPaintManager.queryPaint; | package com.asha.nightowllib.handler.impls;
/**
* Created by hzqiujiadi on 15/11/6.
* hzqiujiadi ashqalcn@gmail.com
*/
public abstract class AbsSkinHandler implements ISkinHandler {
private final static String ANDROID_XML = "http://schemas.android.com/apk/res/android";
private static final String TAG = "AbsSkinHandler";
@Override
public void collect(int mode, View view, Context context, AttributeSet attrs) {
Log.d(TAG, String.format("collected %s %s %s", view, context, attrs));
ColorBox box = ColorBox.newInstance();
onBeforeCollect(view,context,attrs,box);
final Resources.Theme theme = context.getTheme();
int systemStyleResId = 0;
Class clz = this.getClass();
// SystemStyleable
OwlSysStyleable systemStyleable = (OwlSysStyleable) clz.getAnnotation(OwlSysStyleable.class);
if ( systemStyleable != null ){
String value = systemStyleable.value();
systemStyleResId = attrs.getAttributeResourceValue(ANDROID_XML, value, 0);
}
// OwlStyleable
Field[] fields = clz.getFields();
for ( Field field : fields ){
OwlStyleable owlStyleable = field.getAnnotation(OwlStyleable.class);
if ( owlStyleable == null ) continue;
Class scopeClz = field.getDeclaringClass();
OwlAttrScope owlAttrScope = (OwlAttrScope) scopeClz.getAnnotation(OwlAttrScope.class);
if ( owlAttrScope == null ) continue;
int scope = owlAttrScope.value(); | // Path: nightowllib/src/main/java/com/asha/nightowllib/handler/ISkinHandler.java
// public interface ISkinHandler {
// void collect(int mode, View view, Context context, AttributeSet attrs);
// void onSkinChanged(int skin, View view);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/ColorBox.java
// public class ColorBox {
// private int mMode = -1;
// // may override the value, so we use SparseArray
// private SparseArray<Object[]> mBox;
// private ColorBox() {
// mBox = new SparseArray<>(4);
// }
//
// public void put(int attr, int scope, Object... objects){
// mBox.put(attr + scope, objects);
// }
//
// public void refreshSkin(int mode, View view, boolean force){
// if ( force ) mMode = -1;
// refreshSkin(mode,view);
// }
//
// public Object[] get(int attr, int scope){
// return mBox.get( attr + scope );
// }
//
// public void refreshSkin(int mode, View view){
// if ( mMode != mode ){
// int size = mBox.size();
// for (int i = 0; i < size; i++) {
// int attrWithScope = mBox.keyAt(i);
// Object[] res = mBox.valueAt(i);
// IOwlPaint paint = queryPaint(attrWithScope);
// if ( paint != null ) paint.draw(view, res[mode]);
// }
// }
// mMode = mode;
// }
//
// public int getMode() {
// return mMode;
// }
//
// public static ColorBox newInstance() {
// return new ColorBox();
// }
//
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/IOwlPaint.java
// public interface IOwlPaint {
// void draw(View view, Object value);
// Object[] setup(View view, TypedArray a, int attr);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static int[] getStaticFieldIntArraySafely(Field field){
// try {
// return (int[]) field.get(null);
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// return null;
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static void insertSkinBox(View view, ColorBox box){
// view.setTag(NIGHT_OWL_VIEW_TAG, box);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static ColorBox obtainSkinBox(View view){
// Object box = view.getTag(NIGHT_OWL_VIEW_TAG);
// checkNonNull(box,"wtf, it can't be null.");
// if ( box instanceof ColorBox ){
// return (ColorBox) box;
// } else if ( box.equals(EMPTY_TAG) ) {
// Log.d(TAG, "EMPTY_TAG...");
// return null;
// } else {
// Log.e(TAG, "wtf, NIGHT_OWL_VIEW_TAG had been used by someone else.");
// }
// return null;
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/OwlPaintManager.java
// public static IOwlPaint queryPaint(int attrWithScope){
// Class< ? extends IOwlPaint> clz = sPaints.get(attrWithScope);
// if ( clz == null ) return null;
// IOwlPaint instance = sPaintInstances.get(clz);
// if ( instance == null ){
// instance = newInstanceSafely(clz);
// sPaintInstances.put(clz,instance);
// }
// return instance;
// }
// Path: nightowllib/src/main/java/com/asha/nightowllib/handler/impls/AbsSkinHandler.java
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import com.asha.nightowllib.handler.ISkinHandler;
import com.asha.nightowllib.handler.annotations.OwlAttrScope;
import com.asha.nightowllib.handler.annotations.OwlStyleable;
import com.asha.nightowllib.handler.annotations.OwlSysStyleable;
import com.asha.nightowllib.paint.ColorBox;
import com.asha.nightowllib.paint.IOwlPaint;
import java.lang.reflect.Field;
import static com.asha.nightowllib.NightOwlUtil.getStaticFieldIntArraySafely;
import static com.asha.nightowllib.NightOwlUtil.insertSkinBox;
import static com.asha.nightowllib.NightOwlUtil.obtainSkinBox;
import static com.asha.nightowllib.paint.OwlPaintManager.queryPaint;
package com.asha.nightowllib.handler.impls;
/**
* Created by hzqiujiadi on 15/11/6.
* hzqiujiadi ashqalcn@gmail.com
*/
public abstract class AbsSkinHandler implements ISkinHandler {
private final static String ANDROID_XML = "http://schemas.android.com/apk/res/android";
private static final String TAG = "AbsSkinHandler";
@Override
public void collect(int mode, View view, Context context, AttributeSet attrs) {
Log.d(TAG, String.format("collected %s %s %s", view, context, attrs));
ColorBox box = ColorBox.newInstance();
onBeforeCollect(view,context,attrs,box);
final Resources.Theme theme = context.getTheme();
int systemStyleResId = 0;
Class clz = this.getClass();
// SystemStyleable
OwlSysStyleable systemStyleable = (OwlSysStyleable) clz.getAnnotation(OwlSysStyleable.class);
if ( systemStyleable != null ){
String value = systemStyleable.value();
systemStyleResId = attrs.getAttributeResourceValue(ANDROID_XML, value, 0);
}
// OwlStyleable
Field[] fields = clz.getFields();
for ( Field field : fields ){
OwlStyleable owlStyleable = field.getAnnotation(OwlStyleable.class);
if ( owlStyleable == null ) continue;
Class scopeClz = field.getDeclaringClass();
OwlAttrScope owlAttrScope = (OwlAttrScope) scopeClz.getAnnotation(OwlAttrScope.class);
if ( owlAttrScope == null ) continue;
int scope = owlAttrScope.value(); | int[] styleableResId = getStaticFieldIntArraySafely(field); |
ashqal/NightOwl | nightowllib/src/main/java/com/asha/nightowllib/handler/impls/AbsSkinHandler.java | // Path: nightowllib/src/main/java/com/asha/nightowllib/handler/ISkinHandler.java
// public interface ISkinHandler {
// void collect(int mode, View view, Context context, AttributeSet attrs);
// void onSkinChanged(int skin, View view);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/ColorBox.java
// public class ColorBox {
// private int mMode = -1;
// // may override the value, so we use SparseArray
// private SparseArray<Object[]> mBox;
// private ColorBox() {
// mBox = new SparseArray<>(4);
// }
//
// public void put(int attr, int scope, Object... objects){
// mBox.put(attr + scope, objects);
// }
//
// public void refreshSkin(int mode, View view, boolean force){
// if ( force ) mMode = -1;
// refreshSkin(mode,view);
// }
//
// public Object[] get(int attr, int scope){
// return mBox.get( attr + scope );
// }
//
// public void refreshSkin(int mode, View view){
// if ( mMode != mode ){
// int size = mBox.size();
// for (int i = 0; i < size; i++) {
// int attrWithScope = mBox.keyAt(i);
// Object[] res = mBox.valueAt(i);
// IOwlPaint paint = queryPaint(attrWithScope);
// if ( paint != null ) paint.draw(view, res[mode]);
// }
// }
// mMode = mode;
// }
//
// public int getMode() {
// return mMode;
// }
//
// public static ColorBox newInstance() {
// return new ColorBox();
// }
//
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/IOwlPaint.java
// public interface IOwlPaint {
// void draw(View view, Object value);
// Object[] setup(View view, TypedArray a, int attr);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static int[] getStaticFieldIntArraySafely(Field field){
// try {
// return (int[]) field.get(null);
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// return null;
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static void insertSkinBox(View view, ColorBox box){
// view.setTag(NIGHT_OWL_VIEW_TAG, box);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static ColorBox obtainSkinBox(View view){
// Object box = view.getTag(NIGHT_OWL_VIEW_TAG);
// checkNonNull(box,"wtf, it can't be null.");
// if ( box instanceof ColorBox ){
// return (ColorBox) box;
// } else if ( box.equals(EMPTY_TAG) ) {
// Log.d(TAG, "EMPTY_TAG...");
// return null;
// } else {
// Log.e(TAG, "wtf, NIGHT_OWL_VIEW_TAG had been used by someone else.");
// }
// return null;
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/OwlPaintManager.java
// public static IOwlPaint queryPaint(int attrWithScope){
// Class< ? extends IOwlPaint> clz = sPaints.get(attrWithScope);
// if ( clz == null ) return null;
// IOwlPaint instance = sPaintInstances.get(clz);
// if ( instance == null ){
// instance = newInstanceSafely(clz);
// sPaintInstances.put(clz,instance);
// }
// return instance;
// }
| import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import com.asha.nightowllib.handler.ISkinHandler;
import com.asha.nightowllib.handler.annotations.OwlAttrScope;
import com.asha.nightowllib.handler.annotations.OwlStyleable;
import com.asha.nightowllib.handler.annotations.OwlSysStyleable;
import com.asha.nightowllib.paint.ColorBox;
import com.asha.nightowllib.paint.IOwlPaint;
import java.lang.reflect.Field;
import static com.asha.nightowllib.NightOwlUtil.getStaticFieldIntArraySafely;
import static com.asha.nightowllib.NightOwlUtil.insertSkinBox;
import static com.asha.nightowllib.NightOwlUtil.obtainSkinBox;
import static com.asha.nightowllib.paint.OwlPaintManager.queryPaint; |
// SystemStyleable
OwlSysStyleable systemStyleable = (OwlSysStyleable) clz.getAnnotation(OwlSysStyleable.class);
if ( systemStyleable != null ){
String value = systemStyleable.value();
systemStyleResId = attrs.getAttributeResourceValue(ANDROID_XML, value, 0);
}
// OwlStyleable
Field[] fields = clz.getFields();
for ( Field field : fields ){
OwlStyleable owlStyleable = field.getAnnotation(OwlStyleable.class);
if ( owlStyleable == null ) continue;
Class scopeClz = field.getDeclaringClass();
OwlAttrScope owlAttrScope = (OwlAttrScope) scopeClz.getAnnotation(OwlAttrScope.class);
if ( owlAttrScope == null ) continue;
int scope = owlAttrScope.value();
int[] styleableResId = getStaticFieldIntArraySafely(field);
if ( styleableResId == null ) continue;
TypedArray a = theme.obtainStyledAttributes(attrs, styleableResId, 0, systemStyleResId);
if ( a != null ){
obtainStyle(view, box, scope, a);
a.recycle();
}
}
onAfterCollect(view,context,attrs,box); | // Path: nightowllib/src/main/java/com/asha/nightowllib/handler/ISkinHandler.java
// public interface ISkinHandler {
// void collect(int mode, View view, Context context, AttributeSet attrs);
// void onSkinChanged(int skin, View view);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/ColorBox.java
// public class ColorBox {
// private int mMode = -1;
// // may override the value, so we use SparseArray
// private SparseArray<Object[]> mBox;
// private ColorBox() {
// mBox = new SparseArray<>(4);
// }
//
// public void put(int attr, int scope, Object... objects){
// mBox.put(attr + scope, objects);
// }
//
// public void refreshSkin(int mode, View view, boolean force){
// if ( force ) mMode = -1;
// refreshSkin(mode,view);
// }
//
// public Object[] get(int attr, int scope){
// return mBox.get( attr + scope );
// }
//
// public void refreshSkin(int mode, View view){
// if ( mMode != mode ){
// int size = mBox.size();
// for (int i = 0; i < size; i++) {
// int attrWithScope = mBox.keyAt(i);
// Object[] res = mBox.valueAt(i);
// IOwlPaint paint = queryPaint(attrWithScope);
// if ( paint != null ) paint.draw(view, res[mode]);
// }
// }
// mMode = mode;
// }
//
// public int getMode() {
// return mMode;
// }
//
// public static ColorBox newInstance() {
// return new ColorBox();
// }
//
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/IOwlPaint.java
// public interface IOwlPaint {
// void draw(View view, Object value);
// Object[] setup(View view, TypedArray a, int attr);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static int[] getStaticFieldIntArraySafely(Field field){
// try {
// return (int[]) field.get(null);
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// return null;
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static void insertSkinBox(View view, ColorBox box){
// view.setTag(NIGHT_OWL_VIEW_TAG, box);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static ColorBox obtainSkinBox(View view){
// Object box = view.getTag(NIGHT_OWL_VIEW_TAG);
// checkNonNull(box,"wtf, it can't be null.");
// if ( box instanceof ColorBox ){
// return (ColorBox) box;
// } else if ( box.equals(EMPTY_TAG) ) {
// Log.d(TAG, "EMPTY_TAG...");
// return null;
// } else {
// Log.e(TAG, "wtf, NIGHT_OWL_VIEW_TAG had been used by someone else.");
// }
// return null;
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/OwlPaintManager.java
// public static IOwlPaint queryPaint(int attrWithScope){
// Class< ? extends IOwlPaint> clz = sPaints.get(attrWithScope);
// if ( clz == null ) return null;
// IOwlPaint instance = sPaintInstances.get(clz);
// if ( instance == null ){
// instance = newInstanceSafely(clz);
// sPaintInstances.put(clz,instance);
// }
// return instance;
// }
// Path: nightowllib/src/main/java/com/asha/nightowllib/handler/impls/AbsSkinHandler.java
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import com.asha.nightowllib.handler.ISkinHandler;
import com.asha.nightowllib.handler.annotations.OwlAttrScope;
import com.asha.nightowllib.handler.annotations.OwlStyleable;
import com.asha.nightowllib.handler.annotations.OwlSysStyleable;
import com.asha.nightowllib.paint.ColorBox;
import com.asha.nightowllib.paint.IOwlPaint;
import java.lang.reflect.Field;
import static com.asha.nightowllib.NightOwlUtil.getStaticFieldIntArraySafely;
import static com.asha.nightowllib.NightOwlUtil.insertSkinBox;
import static com.asha.nightowllib.NightOwlUtil.obtainSkinBox;
import static com.asha.nightowllib.paint.OwlPaintManager.queryPaint;
// SystemStyleable
OwlSysStyleable systemStyleable = (OwlSysStyleable) clz.getAnnotation(OwlSysStyleable.class);
if ( systemStyleable != null ){
String value = systemStyleable.value();
systemStyleResId = attrs.getAttributeResourceValue(ANDROID_XML, value, 0);
}
// OwlStyleable
Field[] fields = clz.getFields();
for ( Field field : fields ){
OwlStyleable owlStyleable = field.getAnnotation(OwlStyleable.class);
if ( owlStyleable == null ) continue;
Class scopeClz = field.getDeclaringClass();
OwlAttrScope owlAttrScope = (OwlAttrScope) scopeClz.getAnnotation(OwlAttrScope.class);
if ( owlAttrScope == null ) continue;
int scope = owlAttrScope.value();
int[] styleableResId = getStaticFieldIntArraySafely(field);
if ( styleableResId == null ) continue;
TypedArray a = theme.obtainStyledAttributes(attrs, styleableResId, 0, systemStyleResId);
if ( a != null ){
obtainStyle(view, box, scope, a);
a.recycle();
}
}
onAfterCollect(view,context,attrs,box); | insertSkinBox(view, box); |
ashqal/NightOwl | nightowllib/src/main/java/com/asha/nightowllib/handler/impls/AbsSkinHandler.java | // Path: nightowllib/src/main/java/com/asha/nightowllib/handler/ISkinHandler.java
// public interface ISkinHandler {
// void collect(int mode, View view, Context context, AttributeSet attrs);
// void onSkinChanged(int skin, View view);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/ColorBox.java
// public class ColorBox {
// private int mMode = -1;
// // may override the value, so we use SparseArray
// private SparseArray<Object[]> mBox;
// private ColorBox() {
// mBox = new SparseArray<>(4);
// }
//
// public void put(int attr, int scope, Object... objects){
// mBox.put(attr + scope, objects);
// }
//
// public void refreshSkin(int mode, View view, boolean force){
// if ( force ) mMode = -1;
// refreshSkin(mode,view);
// }
//
// public Object[] get(int attr, int scope){
// return mBox.get( attr + scope );
// }
//
// public void refreshSkin(int mode, View view){
// if ( mMode != mode ){
// int size = mBox.size();
// for (int i = 0; i < size; i++) {
// int attrWithScope = mBox.keyAt(i);
// Object[] res = mBox.valueAt(i);
// IOwlPaint paint = queryPaint(attrWithScope);
// if ( paint != null ) paint.draw(view, res[mode]);
// }
// }
// mMode = mode;
// }
//
// public int getMode() {
// return mMode;
// }
//
// public static ColorBox newInstance() {
// return new ColorBox();
// }
//
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/IOwlPaint.java
// public interface IOwlPaint {
// void draw(View view, Object value);
// Object[] setup(View view, TypedArray a, int attr);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static int[] getStaticFieldIntArraySafely(Field field){
// try {
// return (int[]) field.get(null);
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// return null;
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static void insertSkinBox(View view, ColorBox box){
// view.setTag(NIGHT_OWL_VIEW_TAG, box);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static ColorBox obtainSkinBox(View view){
// Object box = view.getTag(NIGHT_OWL_VIEW_TAG);
// checkNonNull(box,"wtf, it can't be null.");
// if ( box instanceof ColorBox ){
// return (ColorBox) box;
// } else if ( box.equals(EMPTY_TAG) ) {
// Log.d(TAG, "EMPTY_TAG...");
// return null;
// } else {
// Log.e(TAG, "wtf, NIGHT_OWL_VIEW_TAG had been used by someone else.");
// }
// return null;
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/OwlPaintManager.java
// public static IOwlPaint queryPaint(int attrWithScope){
// Class< ? extends IOwlPaint> clz = sPaints.get(attrWithScope);
// if ( clz == null ) return null;
// IOwlPaint instance = sPaintInstances.get(clz);
// if ( instance == null ){
// instance = newInstanceSafely(clz);
// sPaintInstances.put(clz,instance);
// }
// return instance;
// }
| import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import com.asha.nightowllib.handler.ISkinHandler;
import com.asha.nightowllib.handler.annotations.OwlAttrScope;
import com.asha.nightowllib.handler.annotations.OwlStyleable;
import com.asha.nightowllib.handler.annotations.OwlSysStyleable;
import com.asha.nightowllib.paint.ColorBox;
import com.asha.nightowllib.paint.IOwlPaint;
import java.lang.reflect.Field;
import static com.asha.nightowllib.NightOwlUtil.getStaticFieldIntArraySafely;
import static com.asha.nightowllib.NightOwlUtil.insertSkinBox;
import static com.asha.nightowllib.NightOwlUtil.obtainSkinBox;
import static com.asha.nightowllib.paint.OwlPaintManager.queryPaint; |
int scope = owlAttrScope.value();
int[] styleableResId = getStaticFieldIntArraySafely(field);
if ( styleableResId == null ) continue;
TypedArray a = theme.obtainStyledAttributes(attrs, styleableResId, 0, systemStyleResId);
if ( a != null ){
obtainStyle(view, box, scope, a);
a.recycle();
}
}
onAfterCollect(view,context,attrs,box);
insertSkinBox(view, box);
// first refresh
box.refreshSkin(mode, view, true);
}
private void obtainStyle(View view
, ColorBox box
, int scope
, TypedArray a
){
int n = a.getIndexCount();
for (int i = 0; i < n; i++) {
int attr = a.getIndex(i);
// look for attr | // Path: nightowllib/src/main/java/com/asha/nightowllib/handler/ISkinHandler.java
// public interface ISkinHandler {
// void collect(int mode, View view, Context context, AttributeSet attrs);
// void onSkinChanged(int skin, View view);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/ColorBox.java
// public class ColorBox {
// private int mMode = -1;
// // may override the value, so we use SparseArray
// private SparseArray<Object[]> mBox;
// private ColorBox() {
// mBox = new SparseArray<>(4);
// }
//
// public void put(int attr, int scope, Object... objects){
// mBox.put(attr + scope, objects);
// }
//
// public void refreshSkin(int mode, View view, boolean force){
// if ( force ) mMode = -1;
// refreshSkin(mode,view);
// }
//
// public Object[] get(int attr, int scope){
// return mBox.get( attr + scope );
// }
//
// public void refreshSkin(int mode, View view){
// if ( mMode != mode ){
// int size = mBox.size();
// for (int i = 0; i < size; i++) {
// int attrWithScope = mBox.keyAt(i);
// Object[] res = mBox.valueAt(i);
// IOwlPaint paint = queryPaint(attrWithScope);
// if ( paint != null ) paint.draw(view, res[mode]);
// }
// }
// mMode = mode;
// }
//
// public int getMode() {
// return mMode;
// }
//
// public static ColorBox newInstance() {
// return new ColorBox();
// }
//
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/IOwlPaint.java
// public interface IOwlPaint {
// void draw(View view, Object value);
// Object[] setup(View view, TypedArray a, int attr);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static int[] getStaticFieldIntArraySafely(Field field){
// try {
// return (int[]) field.get(null);
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// return null;
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static void insertSkinBox(View view, ColorBox box){
// view.setTag(NIGHT_OWL_VIEW_TAG, box);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static ColorBox obtainSkinBox(View view){
// Object box = view.getTag(NIGHT_OWL_VIEW_TAG);
// checkNonNull(box,"wtf, it can't be null.");
// if ( box instanceof ColorBox ){
// return (ColorBox) box;
// } else if ( box.equals(EMPTY_TAG) ) {
// Log.d(TAG, "EMPTY_TAG...");
// return null;
// } else {
// Log.e(TAG, "wtf, NIGHT_OWL_VIEW_TAG had been used by someone else.");
// }
// return null;
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/OwlPaintManager.java
// public static IOwlPaint queryPaint(int attrWithScope){
// Class< ? extends IOwlPaint> clz = sPaints.get(attrWithScope);
// if ( clz == null ) return null;
// IOwlPaint instance = sPaintInstances.get(clz);
// if ( instance == null ){
// instance = newInstanceSafely(clz);
// sPaintInstances.put(clz,instance);
// }
// return instance;
// }
// Path: nightowllib/src/main/java/com/asha/nightowllib/handler/impls/AbsSkinHandler.java
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import com.asha.nightowllib.handler.ISkinHandler;
import com.asha.nightowllib.handler.annotations.OwlAttrScope;
import com.asha.nightowllib.handler.annotations.OwlStyleable;
import com.asha.nightowllib.handler.annotations.OwlSysStyleable;
import com.asha.nightowllib.paint.ColorBox;
import com.asha.nightowllib.paint.IOwlPaint;
import java.lang.reflect.Field;
import static com.asha.nightowllib.NightOwlUtil.getStaticFieldIntArraySafely;
import static com.asha.nightowllib.NightOwlUtil.insertSkinBox;
import static com.asha.nightowllib.NightOwlUtil.obtainSkinBox;
import static com.asha.nightowllib.paint.OwlPaintManager.queryPaint;
int scope = owlAttrScope.value();
int[] styleableResId = getStaticFieldIntArraySafely(field);
if ( styleableResId == null ) continue;
TypedArray a = theme.obtainStyledAttributes(attrs, styleableResId, 0, systemStyleResId);
if ( a != null ){
obtainStyle(view, box, scope, a);
a.recycle();
}
}
onAfterCollect(view,context,attrs,box);
insertSkinBox(view, box);
// first refresh
box.refreshSkin(mode, view, true);
}
private void obtainStyle(View view
, ColorBox box
, int scope
, TypedArray a
){
int n = a.getIndexCount();
for (int i = 0; i < n; i++) {
int attr = a.getIndex(i);
// look for attr | IOwlPaint paint = queryPaint(attr+scope); |
ashqal/NightOwl | nightowllib/src/main/java/com/asha/nightowllib/handler/impls/AbsSkinHandler.java | // Path: nightowllib/src/main/java/com/asha/nightowllib/handler/ISkinHandler.java
// public interface ISkinHandler {
// void collect(int mode, View view, Context context, AttributeSet attrs);
// void onSkinChanged(int skin, View view);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/ColorBox.java
// public class ColorBox {
// private int mMode = -1;
// // may override the value, so we use SparseArray
// private SparseArray<Object[]> mBox;
// private ColorBox() {
// mBox = new SparseArray<>(4);
// }
//
// public void put(int attr, int scope, Object... objects){
// mBox.put(attr + scope, objects);
// }
//
// public void refreshSkin(int mode, View view, boolean force){
// if ( force ) mMode = -1;
// refreshSkin(mode,view);
// }
//
// public Object[] get(int attr, int scope){
// return mBox.get( attr + scope );
// }
//
// public void refreshSkin(int mode, View view){
// if ( mMode != mode ){
// int size = mBox.size();
// for (int i = 0; i < size; i++) {
// int attrWithScope = mBox.keyAt(i);
// Object[] res = mBox.valueAt(i);
// IOwlPaint paint = queryPaint(attrWithScope);
// if ( paint != null ) paint.draw(view, res[mode]);
// }
// }
// mMode = mode;
// }
//
// public int getMode() {
// return mMode;
// }
//
// public static ColorBox newInstance() {
// return new ColorBox();
// }
//
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/IOwlPaint.java
// public interface IOwlPaint {
// void draw(View view, Object value);
// Object[] setup(View view, TypedArray a, int attr);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static int[] getStaticFieldIntArraySafely(Field field){
// try {
// return (int[]) field.get(null);
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// return null;
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static void insertSkinBox(View view, ColorBox box){
// view.setTag(NIGHT_OWL_VIEW_TAG, box);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static ColorBox obtainSkinBox(View view){
// Object box = view.getTag(NIGHT_OWL_VIEW_TAG);
// checkNonNull(box,"wtf, it can't be null.");
// if ( box instanceof ColorBox ){
// return (ColorBox) box;
// } else if ( box.equals(EMPTY_TAG) ) {
// Log.d(TAG, "EMPTY_TAG...");
// return null;
// } else {
// Log.e(TAG, "wtf, NIGHT_OWL_VIEW_TAG had been used by someone else.");
// }
// return null;
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/OwlPaintManager.java
// public static IOwlPaint queryPaint(int attrWithScope){
// Class< ? extends IOwlPaint> clz = sPaints.get(attrWithScope);
// if ( clz == null ) return null;
// IOwlPaint instance = sPaintInstances.get(clz);
// if ( instance == null ){
// instance = newInstanceSafely(clz);
// sPaintInstances.put(clz,instance);
// }
// return instance;
// }
| import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import com.asha.nightowllib.handler.ISkinHandler;
import com.asha.nightowllib.handler.annotations.OwlAttrScope;
import com.asha.nightowllib.handler.annotations.OwlStyleable;
import com.asha.nightowllib.handler.annotations.OwlSysStyleable;
import com.asha.nightowllib.paint.ColorBox;
import com.asha.nightowllib.paint.IOwlPaint;
import java.lang.reflect.Field;
import static com.asha.nightowllib.NightOwlUtil.getStaticFieldIntArraySafely;
import static com.asha.nightowllib.NightOwlUtil.insertSkinBox;
import static com.asha.nightowllib.NightOwlUtil.obtainSkinBox;
import static com.asha.nightowllib.paint.OwlPaintManager.queryPaint; |
int scope = owlAttrScope.value();
int[] styleableResId = getStaticFieldIntArraySafely(field);
if ( styleableResId == null ) continue;
TypedArray a = theme.obtainStyledAttributes(attrs, styleableResId, 0, systemStyleResId);
if ( a != null ){
obtainStyle(view, box, scope, a);
a.recycle();
}
}
onAfterCollect(view,context,attrs,box);
insertSkinBox(view, box);
// first refresh
box.refreshSkin(mode, view, true);
}
private void obtainStyle(View view
, ColorBox box
, int scope
, TypedArray a
){
int n = a.getIndexCount();
for (int i = 0; i < n; i++) {
int attr = a.getIndex(i);
// look for attr | // Path: nightowllib/src/main/java/com/asha/nightowllib/handler/ISkinHandler.java
// public interface ISkinHandler {
// void collect(int mode, View view, Context context, AttributeSet attrs);
// void onSkinChanged(int skin, View view);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/ColorBox.java
// public class ColorBox {
// private int mMode = -1;
// // may override the value, so we use SparseArray
// private SparseArray<Object[]> mBox;
// private ColorBox() {
// mBox = new SparseArray<>(4);
// }
//
// public void put(int attr, int scope, Object... objects){
// mBox.put(attr + scope, objects);
// }
//
// public void refreshSkin(int mode, View view, boolean force){
// if ( force ) mMode = -1;
// refreshSkin(mode,view);
// }
//
// public Object[] get(int attr, int scope){
// return mBox.get( attr + scope );
// }
//
// public void refreshSkin(int mode, View view){
// if ( mMode != mode ){
// int size = mBox.size();
// for (int i = 0; i < size; i++) {
// int attrWithScope = mBox.keyAt(i);
// Object[] res = mBox.valueAt(i);
// IOwlPaint paint = queryPaint(attrWithScope);
// if ( paint != null ) paint.draw(view, res[mode]);
// }
// }
// mMode = mode;
// }
//
// public int getMode() {
// return mMode;
// }
//
// public static ColorBox newInstance() {
// return new ColorBox();
// }
//
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/IOwlPaint.java
// public interface IOwlPaint {
// void draw(View view, Object value);
// Object[] setup(View view, TypedArray a, int attr);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static int[] getStaticFieldIntArraySafely(Field field){
// try {
// return (int[]) field.get(null);
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// return null;
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static void insertSkinBox(View view, ColorBox box){
// view.setTag(NIGHT_OWL_VIEW_TAG, box);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static ColorBox obtainSkinBox(View view){
// Object box = view.getTag(NIGHT_OWL_VIEW_TAG);
// checkNonNull(box,"wtf, it can't be null.");
// if ( box instanceof ColorBox ){
// return (ColorBox) box;
// } else if ( box.equals(EMPTY_TAG) ) {
// Log.d(TAG, "EMPTY_TAG...");
// return null;
// } else {
// Log.e(TAG, "wtf, NIGHT_OWL_VIEW_TAG had been used by someone else.");
// }
// return null;
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/OwlPaintManager.java
// public static IOwlPaint queryPaint(int attrWithScope){
// Class< ? extends IOwlPaint> clz = sPaints.get(attrWithScope);
// if ( clz == null ) return null;
// IOwlPaint instance = sPaintInstances.get(clz);
// if ( instance == null ){
// instance = newInstanceSafely(clz);
// sPaintInstances.put(clz,instance);
// }
// return instance;
// }
// Path: nightowllib/src/main/java/com/asha/nightowllib/handler/impls/AbsSkinHandler.java
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import com.asha.nightowllib.handler.ISkinHandler;
import com.asha.nightowllib.handler.annotations.OwlAttrScope;
import com.asha.nightowllib.handler.annotations.OwlStyleable;
import com.asha.nightowllib.handler.annotations.OwlSysStyleable;
import com.asha.nightowllib.paint.ColorBox;
import com.asha.nightowllib.paint.IOwlPaint;
import java.lang.reflect.Field;
import static com.asha.nightowllib.NightOwlUtil.getStaticFieldIntArraySafely;
import static com.asha.nightowllib.NightOwlUtil.insertSkinBox;
import static com.asha.nightowllib.NightOwlUtil.obtainSkinBox;
import static com.asha.nightowllib.paint.OwlPaintManager.queryPaint;
int scope = owlAttrScope.value();
int[] styleableResId = getStaticFieldIntArraySafely(field);
if ( styleableResId == null ) continue;
TypedArray a = theme.obtainStyledAttributes(attrs, styleableResId, 0, systemStyleResId);
if ( a != null ){
obtainStyle(view, box, scope, a);
a.recycle();
}
}
onAfterCollect(view,context,attrs,box);
insertSkinBox(view, box);
// first refresh
box.refreshSkin(mode, view, true);
}
private void obtainStyle(View view
, ColorBox box
, int scope
, TypedArray a
){
int n = a.getIndexCount();
for (int i = 0; i < n; i++) {
int attr = a.getIndex(i);
// look for attr | IOwlPaint paint = queryPaint(attr+scope); |
ashqal/NightOwl | nightowllib/src/main/java/com/asha/nightowllib/handler/impls/AbsSkinHandler.java | // Path: nightowllib/src/main/java/com/asha/nightowllib/handler/ISkinHandler.java
// public interface ISkinHandler {
// void collect(int mode, View view, Context context, AttributeSet attrs);
// void onSkinChanged(int skin, View view);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/ColorBox.java
// public class ColorBox {
// private int mMode = -1;
// // may override the value, so we use SparseArray
// private SparseArray<Object[]> mBox;
// private ColorBox() {
// mBox = new SparseArray<>(4);
// }
//
// public void put(int attr, int scope, Object... objects){
// mBox.put(attr + scope, objects);
// }
//
// public void refreshSkin(int mode, View view, boolean force){
// if ( force ) mMode = -1;
// refreshSkin(mode,view);
// }
//
// public Object[] get(int attr, int scope){
// return mBox.get( attr + scope );
// }
//
// public void refreshSkin(int mode, View view){
// if ( mMode != mode ){
// int size = mBox.size();
// for (int i = 0; i < size; i++) {
// int attrWithScope = mBox.keyAt(i);
// Object[] res = mBox.valueAt(i);
// IOwlPaint paint = queryPaint(attrWithScope);
// if ( paint != null ) paint.draw(view, res[mode]);
// }
// }
// mMode = mode;
// }
//
// public int getMode() {
// return mMode;
// }
//
// public static ColorBox newInstance() {
// return new ColorBox();
// }
//
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/IOwlPaint.java
// public interface IOwlPaint {
// void draw(View view, Object value);
// Object[] setup(View view, TypedArray a, int attr);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static int[] getStaticFieldIntArraySafely(Field field){
// try {
// return (int[]) field.get(null);
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// return null;
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static void insertSkinBox(View view, ColorBox box){
// view.setTag(NIGHT_OWL_VIEW_TAG, box);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static ColorBox obtainSkinBox(View view){
// Object box = view.getTag(NIGHT_OWL_VIEW_TAG);
// checkNonNull(box,"wtf, it can't be null.");
// if ( box instanceof ColorBox ){
// return (ColorBox) box;
// } else if ( box.equals(EMPTY_TAG) ) {
// Log.d(TAG, "EMPTY_TAG...");
// return null;
// } else {
// Log.e(TAG, "wtf, NIGHT_OWL_VIEW_TAG had been used by someone else.");
// }
// return null;
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/OwlPaintManager.java
// public static IOwlPaint queryPaint(int attrWithScope){
// Class< ? extends IOwlPaint> clz = sPaints.get(attrWithScope);
// if ( clz == null ) return null;
// IOwlPaint instance = sPaintInstances.get(clz);
// if ( instance == null ){
// instance = newInstanceSafely(clz);
// sPaintInstances.put(clz,instance);
// }
// return instance;
// }
| import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import com.asha.nightowllib.handler.ISkinHandler;
import com.asha.nightowllib.handler.annotations.OwlAttrScope;
import com.asha.nightowllib.handler.annotations.OwlStyleable;
import com.asha.nightowllib.handler.annotations.OwlSysStyleable;
import com.asha.nightowllib.paint.ColorBox;
import com.asha.nightowllib.paint.IOwlPaint;
import java.lang.reflect.Field;
import static com.asha.nightowllib.NightOwlUtil.getStaticFieldIntArraySafely;
import static com.asha.nightowllib.NightOwlUtil.insertSkinBox;
import static com.asha.nightowllib.NightOwlUtil.obtainSkinBox;
import static com.asha.nightowllib.paint.OwlPaintManager.queryPaint; |
// first refresh
box.refreshSkin(mode, view, true);
}
private void obtainStyle(View view
, ColorBox box
, int scope
, TypedArray a
){
int n = a.getIndexCount();
for (int i = 0; i < n; i++) {
int attr = a.getIndex(i);
// look for attr
IOwlPaint paint = queryPaint(attr+scope);
if ( paint == null) {
Log.d(TAG, "Can't find paint of attr:" + attr + " scope:" + scope); continue; }
Object[] values = paint.setup(view,a,attr);
if ( values != null ) box.put(attr, scope, values);
}
}
protected void onBeforeCollect(View view, Context context, AttributeSet attrs, ColorBox box){}
protected void onAfterCollect(View view, Context context, AttributeSet attrs, ColorBox box){}
@Override
final public void onSkinChanged(int skin, View view) { | // Path: nightowllib/src/main/java/com/asha/nightowllib/handler/ISkinHandler.java
// public interface ISkinHandler {
// void collect(int mode, View view, Context context, AttributeSet attrs);
// void onSkinChanged(int skin, View view);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/ColorBox.java
// public class ColorBox {
// private int mMode = -1;
// // may override the value, so we use SparseArray
// private SparseArray<Object[]> mBox;
// private ColorBox() {
// mBox = new SparseArray<>(4);
// }
//
// public void put(int attr, int scope, Object... objects){
// mBox.put(attr + scope, objects);
// }
//
// public void refreshSkin(int mode, View view, boolean force){
// if ( force ) mMode = -1;
// refreshSkin(mode,view);
// }
//
// public Object[] get(int attr, int scope){
// return mBox.get( attr + scope );
// }
//
// public void refreshSkin(int mode, View view){
// if ( mMode != mode ){
// int size = mBox.size();
// for (int i = 0; i < size; i++) {
// int attrWithScope = mBox.keyAt(i);
// Object[] res = mBox.valueAt(i);
// IOwlPaint paint = queryPaint(attrWithScope);
// if ( paint != null ) paint.draw(view, res[mode]);
// }
// }
// mMode = mode;
// }
//
// public int getMode() {
// return mMode;
// }
//
// public static ColorBox newInstance() {
// return new ColorBox();
// }
//
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/IOwlPaint.java
// public interface IOwlPaint {
// void draw(View view, Object value);
// Object[] setup(View view, TypedArray a, int attr);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static int[] getStaticFieldIntArraySafely(Field field){
// try {
// return (int[]) field.get(null);
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// return null;
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static void insertSkinBox(View view, ColorBox box){
// view.setTag(NIGHT_OWL_VIEW_TAG, box);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static ColorBox obtainSkinBox(View view){
// Object box = view.getTag(NIGHT_OWL_VIEW_TAG);
// checkNonNull(box,"wtf, it can't be null.");
// if ( box instanceof ColorBox ){
// return (ColorBox) box;
// } else if ( box.equals(EMPTY_TAG) ) {
// Log.d(TAG, "EMPTY_TAG...");
// return null;
// } else {
// Log.e(TAG, "wtf, NIGHT_OWL_VIEW_TAG had been used by someone else.");
// }
// return null;
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/OwlPaintManager.java
// public static IOwlPaint queryPaint(int attrWithScope){
// Class< ? extends IOwlPaint> clz = sPaints.get(attrWithScope);
// if ( clz == null ) return null;
// IOwlPaint instance = sPaintInstances.get(clz);
// if ( instance == null ){
// instance = newInstanceSafely(clz);
// sPaintInstances.put(clz,instance);
// }
// return instance;
// }
// Path: nightowllib/src/main/java/com/asha/nightowllib/handler/impls/AbsSkinHandler.java
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import com.asha.nightowllib.handler.ISkinHandler;
import com.asha.nightowllib.handler.annotations.OwlAttrScope;
import com.asha.nightowllib.handler.annotations.OwlStyleable;
import com.asha.nightowllib.handler.annotations.OwlSysStyleable;
import com.asha.nightowllib.paint.ColorBox;
import com.asha.nightowllib.paint.IOwlPaint;
import java.lang.reflect.Field;
import static com.asha.nightowllib.NightOwlUtil.getStaticFieldIntArraySafely;
import static com.asha.nightowllib.NightOwlUtil.insertSkinBox;
import static com.asha.nightowllib.NightOwlUtil.obtainSkinBox;
import static com.asha.nightowllib.paint.OwlPaintManager.queryPaint;
// first refresh
box.refreshSkin(mode, view, true);
}
private void obtainStyle(View view
, ColorBox box
, int scope
, TypedArray a
){
int n = a.getIndexCount();
for (int i = 0; i < n; i++) {
int attr = a.getIndex(i);
// look for attr
IOwlPaint paint = queryPaint(attr+scope);
if ( paint == null) {
Log.d(TAG, "Can't find paint of attr:" + attr + " scope:" + scope); continue; }
Object[] values = paint.setup(view,a,attr);
if ( values != null ) box.put(attr, scope, values);
}
}
protected void onBeforeCollect(View view, Context context, AttributeSet attrs, ColorBox box){}
protected void onAfterCollect(View view, Context context, AttributeSet attrs, ColorBox box){}
@Override
final public void onSkinChanged(int skin, View view) { | ColorBox box = obtainSkinBox(view); |
ashqal/NightOwl | nightowllib/src/main/java/com/asha/nightowllib/inflater/LastChance2Inflater.java | // Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static void checkNonNull(Object obj,String msg){
// if ( obj == null ) throw new NullPointerException(msg);
// }
| import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import static com.asha.nightowllib.NightOwlUtil.checkNonNull; | package com.asha.nightowllib.inflater;
/**
* Created by hzqiujiadi on 15/11/7.
* hzqiujiadi ashqalcn@gmail.com
*/
public class LastChance2Inflater {
private InjectedInflaterBase mInflater;
protected LastChance2Inflater(InjectedInflaterBase inflater) {
mInflater = inflater;
}
protected View lastChance2CreateView(View parent, String name, Context context, AttributeSet attrs){
View view = null;
Object[] tmpConstructorArgs = mInflater.getConstructorArgs(); | // Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static void checkNonNull(Object obj,String msg){
// if ( obj == null ) throw new NullPointerException(msg);
// }
// Path: nightowllib/src/main/java/com/asha/nightowllib/inflater/LastChance2Inflater.java
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import static com.asha.nightowllib.NightOwlUtil.checkNonNull;
package com.asha.nightowllib.inflater;
/**
* Created by hzqiujiadi on 15/11/7.
* hzqiujiadi ashqalcn@gmail.com
*/
public class LastChance2Inflater {
private InjectedInflaterBase mInflater;
protected LastChance2Inflater(InjectedInflaterBase inflater) {
mInflater = inflater;
}
protected View lastChance2CreateView(View parent, String name, Context context, AttributeSet attrs){
View view = null;
Object[] tmpConstructorArgs = mInflater.getConstructorArgs(); | checkNonNull(tmpConstructorArgs,"LayoutInflater mConstructorArgs is null."); |
ashqal/NightOwl | nightowllib/src/main/java/com/asha/nightowllib/handler/impls/TextViewHandler.java | // Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlTable.java
// public class NightOwlTable {
// protected static void init(){
// registerHandler(ListViewHandler.class);
// registerHandler(ImageViewHandler.class);
// registerHandler(TextViewHandler.class);
// registerHandler(ButtonHandler.class);
// registerHandler(ViewHandler.class);
// }
//
// @OwlAttrScope(2000) public interface OwlView {
// @OwlStyleable int[] NightOwl_View = R.styleable.NightOwl_View;
// @OwlAttr(BackgroundPaint.class) int NightOwl_View_night_background = R.styleable.NightOwl_View_night_background;
// @OwlAttr(AlphaPaint.class) int NightOwl_View_night_alpha = R.styleable.NightOwl_View_night_alpha;
// }
//
// @OwlAttrScope(2100) public interface OwlTextView extends OwlView {
// @OwlStyleable int[] NightOwl_TextView = R.styleable.NightOwl_TextView;
// @OwlAttr(TextColorPaint.class) int NightOwl_TextView_night_textColor = R.styleable.NightOwl_TextView_night_textColor;
// @OwlAttr(TextColorPaint.class) int NightOwl_TextView_night_textColorHint = R.styleable.NightOwl_TextView_night_textColorHint;
// }
//
// @OwlAttrScope(2200) public interface OwlButton extends OwlTextView {
// }
//
// @OwlAttrScope(2300) public interface OwlImageView extends OwlView {
// @OwlStyleable int[] NightOwl_ImageView = R.styleable.NightOwl_ImageView;
// @OwlAttr(ImageViewSrcPaint.class) int NightOwl_ImageView_night_src = R.styleable.NightOwl_ImageView_night_src;
// }
//
// @OwlAttrScope(2400) public interface OwlListView extends OwlView {
// @OwlStyleable int[] NightOwl_ListView = R.styleable.NightOwl_ListView;
// @OwlAttr(ListViewDividerPaint.class) int NightOwl_ListView_night_divider = R.styleable.NightOwl_ListView_night_divider;
// @OwlAttr(ListViewSelectorPaint.class) int NightOwl_ListView_night_listSelector = R.styleable.NightOwl_ListView_night_listSelector;
// }
// }
| import android.widget.TextView;
import com.asha.nightowllib.NightOwlTable;
import com.asha.nightowllib.handler.annotations.OwlHandle;
import com.asha.nightowllib.handler.annotations.OwlSysStyleable; | package com.asha.nightowllib.handler.impls;
/**
* Created by hzqiujiadi on 15/11/5.
* hzqiujiadi ashqalcn@gmail.com
*/
@OwlSysStyleable("textAppearance")
@OwlHandle({TextView.class}) | // Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlTable.java
// public class NightOwlTable {
// protected static void init(){
// registerHandler(ListViewHandler.class);
// registerHandler(ImageViewHandler.class);
// registerHandler(TextViewHandler.class);
// registerHandler(ButtonHandler.class);
// registerHandler(ViewHandler.class);
// }
//
// @OwlAttrScope(2000) public interface OwlView {
// @OwlStyleable int[] NightOwl_View = R.styleable.NightOwl_View;
// @OwlAttr(BackgroundPaint.class) int NightOwl_View_night_background = R.styleable.NightOwl_View_night_background;
// @OwlAttr(AlphaPaint.class) int NightOwl_View_night_alpha = R.styleable.NightOwl_View_night_alpha;
// }
//
// @OwlAttrScope(2100) public interface OwlTextView extends OwlView {
// @OwlStyleable int[] NightOwl_TextView = R.styleable.NightOwl_TextView;
// @OwlAttr(TextColorPaint.class) int NightOwl_TextView_night_textColor = R.styleable.NightOwl_TextView_night_textColor;
// @OwlAttr(TextColorPaint.class) int NightOwl_TextView_night_textColorHint = R.styleable.NightOwl_TextView_night_textColorHint;
// }
//
// @OwlAttrScope(2200) public interface OwlButton extends OwlTextView {
// }
//
// @OwlAttrScope(2300) public interface OwlImageView extends OwlView {
// @OwlStyleable int[] NightOwl_ImageView = R.styleable.NightOwl_ImageView;
// @OwlAttr(ImageViewSrcPaint.class) int NightOwl_ImageView_night_src = R.styleable.NightOwl_ImageView_night_src;
// }
//
// @OwlAttrScope(2400) public interface OwlListView extends OwlView {
// @OwlStyleable int[] NightOwl_ListView = R.styleable.NightOwl_ListView;
// @OwlAttr(ListViewDividerPaint.class) int NightOwl_ListView_night_divider = R.styleable.NightOwl_ListView_night_divider;
// @OwlAttr(ListViewSelectorPaint.class) int NightOwl_ListView_night_listSelector = R.styleable.NightOwl_ListView_night_listSelector;
// }
// }
// Path: nightowllib/src/main/java/com/asha/nightowllib/handler/impls/TextViewHandler.java
import android.widget.TextView;
import com.asha.nightowllib.NightOwlTable;
import com.asha.nightowllib.handler.annotations.OwlHandle;
import com.asha.nightowllib.handler.annotations.OwlSysStyleable;
package com.asha.nightowllib.handler.impls;
/**
* Created by hzqiujiadi on 15/11/5.
* hzqiujiadi ashqalcn@gmail.com
*/
@OwlSysStyleable("textAppearance")
@OwlHandle({TextView.class}) | public class TextViewHandler extends AbsSkinHandler implements NightOwlTable.OwlTextView { |
ashqal/NightOwl | nightowllib/src/main/java/com/asha/nightowllib/observer/OwlViewContext.java | // Path: nightowllib/src/main/java/com/asha/nightowllib/observer/impls/AdditionThemeObserver.java
// public class AdditionThemeObserver implements IOwlObserverWithId {
//
// private static final String TAG = "AdditionThemeObserver";
// private int mThemeDay;
// private int mThemeNight;
// public AdditionThemeObserver(int themeDay, int themeNight) {
// mThemeDay = themeDay;
// mThemeNight = themeNight;
// }
//
// @Override
// public int getObserverId() {
// return AdditionThemeObserver.this.hashCode();
// }
//
// @Override
// public void onSkinChange(int mode, Activity activity) {
// int theme = mode == 0 ? mThemeDay : mThemeNight;
// activity.getTheme().applyStyle(theme, true);
//
// //Log.e(TAG, String.format("%s %d", activity.getTheme(), theme));
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/observer/impls/NavBarObserver.java
// public class NavBarObserver implements IOwlObserverWithId {
// int mNavigationBarColor;
// int mNavigationBarColorNight;
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// public NavBarObserver(Activity activity, TypedArray a, int attr) {
// Window window = activity.getWindow();
// mNavigationBarColor = window.getNavigationBarColor();
// mNavigationBarColorNight = a.getColor(attr,mNavigationBarColor);
// }
//
// @Override
// public int getObserverId() {
// return NavBarObserver.this.hashCode();
// }
//
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// @Override
// public void onSkinChange(int mode, Activity activity) {
// activity.getWindow().setNavigationBarColor( mode == 0 ? mNavigationBarColor : mNavigationBarColorNight);
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/observer/impls/StatusBarObserver.java
// public class StatusBarObserver implements IOwlObserverWithId {
// int mStatusBarColor;
// int mStatusBarColorNight;
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// public StatusBarObserver(Activity activity, TypedArray a, int attr) {
// Window window = activity.getWindow();
// mStatusBarColor = window.getStatusBarColor();
// mStatusBarColorNight = a.getColor(attr,mStatusBarColorNight);
// }
//
// @Override
// public int getObserverId() {
// return StatusBarObserver.this.hashCode();
// }
//
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// @Override
// public void onSkinChange(int mode, Activity activity) {
// activity.getWindow().setStatusBarColor( mode == 0 ? mStatusBarColor : mStatusBarColorNight);
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static boolean checkBeforeLollipop(){
// if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) return true;
// else return false;
// }
| import android.app.Activity;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.util.SparseArray;
import com.asha.nightowllib.R;
import com.asha.nightowllib.observer.impls.AdditionThemeObserver;
import com.asha.nightowllib.observer.impls.NavBarObserver;
import com.asha.nightowllib.observer.impls.StatusBarObserver;
import static com.asha.nightowllib.NightOwlUtil.checkBeforeLollipop; | package com.asha.nightowllib.observer;
/**
* Created by hzqiujiadi on 15/11/9.
* hzqiujiadi ashqalcn@gmail.com
*/
public class OwlViewContext {
private int mLastMode = -1;
private SparseArray<IOwlObserverWithId> observers;
public OwlViewContext() {
observers = new SparseArray<>();
}
public void registerObserver( IOwlObserverWithId owlObserver ){
observers.put(owlObserver.getObserverId(), owlObserver);
}
public void unregisterObserver( IOwlObserverWithId owlObserver ){
observers.delete(owlObserver.getObserverId());
}
public void notifyObserver(int mode, Activity activity){
if ( mode == mLastMode ) return;
mLastMode = mode;
int size = observers.size();
for (int i = 0; i < size; i++) {
IOwlObserverWithId owlObserver = observers.valueAt(i);
owlObserver.onSkinChange(mode, activity);
}
}
public void setupWithCurrentActivity(Activity activity){
Resources.Theme theme = activity.getTheme();
TypedArray a = theme.obtainStyledAttributes(R.styleable.NightOwl_Theme);
if (a != null) { | // Path: nightowllib/src/main/java/com/asha/nightowllib/observer/impls/AdditionThemeObserver.java
// public class AdditionThemeObserver implements IOwlObserverWithId {
//
// private static final String TAG = "AdditionThemeObserver";
// private int mThemeDay;
// private int mThemeNight;
// public AdditionThemeObserver(int themeDay, int themeNight) {
// mThemeDay = themeDay;
// mThemeNight = themeNight;
// }
//
// @Override
// public int getObserverId() {
// return AdditionThemeObserver.this.hashCode();
// }
//
// @Override
// public void onSkinChange(int mode, Activity activity) {
// int theme = mode == 0 ? mThemeDay : mThemeNight;
// activity.getTheme().applyStyle(theme, true);
//
// //Log.e(TAG, String.format("%s %d", activity.getTheme(), theme));
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/observer/impls/NavBarObserver.java
// public class NavBarObserver implements IOwlObserverWithId {
// int mNavigationBarColor;
// int mNavigationBarColorNight;
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// public NavBarObserver(Activity activity, TypedArray a, int attr) {
// Window window = activity.getWindow();
// mNavigationBarColor = window.getNavigationBarColor();
// mNavigationBarColorNight = a.getColor(attr,mNavigationBarColor);
// }
//
// @Override
// public int getObserverId() {
// return NavBarObserver.this.hashCode();
// }
//
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// @Override
// public void onSkinChange(int mode, Activity activity) {
// activity.getWindow().setNavigationBarColor( mode == 0 ? mNavigationBarColor : mNavigationBarColorNight);
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/observer/impls/StatusBarObserver.java
// public class StatusBarObserver implements IOwlObserverWithId {
// int mStatusBarColor;
// int mStatusBarColorNight;
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// public StatusBarObserver(Activity activity, TypedArray a, int attr) {
// Window window = activity.getWindow();
// mStatusBarColor = window.getStatusBarColor();
// mStatusBarColorNight = a.getColor(attr,mStatusBarColorNight);
// }
//
// @Override
// public int getObserverId() {
// return StatusBarObserver.this.hashCode();
// }
//
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// @Override
// public void onSkinChange(int mode, Activity activity) {
// activity.getWindow().setStatusBarColor( mode == 0 ? mStatusBarColor : mStatusBarColorNight);
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static boolean checkBeforeLollipop(){
// if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) return true;
// else return false;
// }
// Path: nightowllib/src/main/java/com/asha/nightowllib/observer/OwlViewContext.java
import android.app.Activity;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.util.SparseArray;
import com.asha.nightowllib.R;
import com.asha.nightowllib.observer.impls.AdditionThemeObserver;
import com.asha.nightowllib.observer.impls.NavBarObserver;
import com.asha.nightowllib.observer.impls.StatusBarObserver;
import static com.asha.nightowllib.NightOwlUtil.checkBeforeLollipop;
package com.asha.nightowllib.observer;
/**
* Created by hzqiujiadi on 15/11/9.
* hzqiujiadi ashqalcn@gmail.com
*/
public class OwlViewContext {
private int mLastMode = -1;
private SparseArray<IOwlObserverWithId> observers;
public OwlViewContext() {
observers = new SparseArray<>();
}
public void registerObserver( IOwlObserverWithId owlObserver ){
observers.put(owlObserver.getObserverId(), owlObserver);
}
public void unregisterObserver( IOwlObserverWithId owlObserver ){
observers.delete(owlObserver.getObserverId());
}
public void notifyObserver(int mode, Activity activity){
if ( mode == mLastMode ) return;
mLastMode = mode;
int size = observers.size();
for (int i = 0; i < size; i++) {
IOwlObserverWithId owlObserver = observers.valueAt(i);
owlObserver.onSkinChange(mode, activity);
}
}
public void setupWithCurrentActivity(Activity activity){
Resources.Theme theme = activity.getTheme();
TypedArray a = theme.obtainStyledAttributes(R.styleable.NightOwl_Theme);
if (a != null) { | if ( !checkBeforeLollipop() ){ |
ashqal/NightOwl | nightowllib/src/main/java/com/asha/nightowllib/observer/OwlViewContext.java | // Path: nightowllib/src/main/java/com/asha/nightowllib/observer/impls/AdditionThemeObserver.java
// public class AdditionThemeObserver implements IOwlObserverWithId {
//
// private static final String TAG = "AdditionThemeObserver";
// private int mThemeDay;
// private int mThemeNight;
// public AdditionThemeObserver(int themeDay, int themeNight) {
// mThemeDay = themeDay;
// mThemeNight = themeNight;
// }
//
// @Override
// public int getObserverId() {
// return AdditionThemeObserver.this.hashCode();
// }
//
// @Override
// public void onSkinChange(int mode, Activity activity) {
// int theme = mode == 0 ? mThemeDay : mThemeNight;
// activity.getTheme().applyStyle(theme, true);
//
// //Log.e(TAG, String.format("%s %d", activity.getTheme(), theme));
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/observer/impls/NavBarObserver.java
// public class NavBarObserver implements IOwlObserverWithId {
// int mNavigationBarColor;
// int mNavigationBarColorNight;
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// public NavBarObserver(Activity activity, TypedArray a, int attr) {
// Window window = activity.getWindow();
// mNavigationBarColor = window.getNavigationBarColor();
// mNavigationBarColorNight = a.getColor(attr,mNavigationBarColor);
// }
//
// @Override
// public int getObserverId() {
// return NavBarObserver.this.hashCode();
// }
//
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// @Override
// public void onSkinChange(int mode, Activity activity) {
// activity.getWindow().setNavigationBarColor( mode == 0 ? mNavigationBarColor : mNavigationBarColorNight);
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/observer/impls/StatusBarObserver.java
// public class StatusBarObserver implements IOwlObserverWithId {
// int mStatusBarColor;
// int mStatusBarColorNight;
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// public StatusBarObserver(Activity activity, TypedArray a, int attr) {
// Window window = activity.getWindow();
// mStatusBarColor = window.getStatusBarColor();
// mStatusBarColorNight = a.getColor(attr,mStatusBarColorNight);
// }
//
// @Override
// public int getObserverId() {
// return StatusBarObserver.this.hashCode();
// }
//
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// @Override
// public void onSkinChange(int mode, Activity activity) {
// activity.getWindow().setStatusBarColor( mode == 0 ? mStatusBarColor : mStatusBarColorNight);
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static boolean checkBeforeLollipop(){
// if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) return true;
// else return false;
// }
| import android.app.Activity;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.util.SparseArray;
import com.asha.nightowllib.R;
import com.asha.nightowllib.observer.impls.AdditionThemeObserver;
import com.asha.nightowllib.observer.impls.NavBarObserver;
import com.asha.nightowllib.observer.impls.StatusBarObserver;
import static com.asha.nightowllib.NightOwlUtil.checkBeforeLollipop; | package com.asha.nightowllib.observer;
/**
* Created by hzqiujiadi on 15/11/9.
* hzqiujiadi ashqalcn@gmail.com
*/
public class OwlViewContext {
private int mLastMode = -1;
private SparseArray<IOwlObserverWithId> observers;
public OwlViewContext() {
observers = new SparseArray<>();
}
public void registerObserver( IOwlObserverWithId owlObserver ){
observers.put(owlObserver.getObserverId(), owlObserver);
}
public void unregisterObserver( IOwlObserverWithId owlObserver ){
observers.delete(owlObserver.getObserverId());
}
public void notifyObserver(int mode, Activity activity){
if ( mode == mLastMode ) return;
mLastMode = mode;
int size = observers.size();
for (int i = 0; i < size; i++) {
IOwlObserverWithId owlObserver = observers.valueAt(i);
owlObserver.onSkinChange(mode, activity);
}
}
public void setupWithCurrentActivity(Activity activity){
Resources.Theme theme = activity.getTheme();
TypedArray a = theme.obtainStyledAttributes(R.styleable.NightOwl_Theme);
if (a != null) {
if ( !checkBeforeLollipop() ){
if ( a.hasValue(R.styleable.NightOwl_Theme_night_navigationBarColor) ) | // Path: nightowllib/src/main/java/com/asha/nightowllib/observer/impls/AdditionThemeObserver.java
// public class AdditionThemeObserver implements IOwlObserverWithId {
//
// private static final String TAG = "AdditionThemeObserver";
// private int mThemeDay;
// private int mThemeNight;
// public AdditionThemeObserver(int themeDay, int themeNight) {
// mThemeDay = themeDay;
// mThemeNight = themeNight;
// }
//
// @Override
// public int getObserverId() {
// return AdditionThemeObserver.this.hashCode();
// }
//
// @Override
// public void onSkinChange(int mode, Activity activity) {
// int theme = mode == 0 ? mThemeDay : mThemeNight;
// activity.getTheme().applyStyle(theme, true);
//
// //Log.e(TAG, String.format("%s %d", activity.getTheme(), theme));
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/observer/impls/NavBarObserver.java
// public class NavBarObserver implements IOwlObserverWithId {
// int mNavigationBarColor;
// int mNavigationBarColorNight;
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// public NavBarObserver(Activity activity, TypedArray a, int attr) {
// Window window = activity.getWindow();
// mNavigationBarColor = window.getNavigationBarColor();
// mNavigationBarColorNight = a.getColor(attr,mNavigationBarColor);
// }
//
// @Override
// public int getObserverId() {
// return NavBarObserver.this.hashCode();
// }
//
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// @Override
// public void onSkinChange(int mode, Activity activity) {
// activity.getWindow().setNavigationBarColor( mode == 0 ? mNavigationBarColor : mNavigationBarColorNight);
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/observer/impls/StatusBarObserver.java
// public class StatusBarObserver implements IOwlObserverWithId {
// int mStatusBarColor;
// int mStatusBarColorNight;
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// public StatusBarObserver(Activity activity, TypedArray a, int attr) {
// Window window = activity.getWindow();
// mStatusBarColor = window.getStatusBarColor();
// mStatusBarColorNight = a.getColor(attr,mStatusBarColorNight);
// }
//
// @Override
// public int getObserverId() {
// return StatusBarObserver.this.hashCode();
// }
//
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// @Override
// public void onSkinChange(int mode, Activity activity) {
// activity.getWindow().setStatusBarColor( mode == 0 ? mStatusBarColor : mStatusBarColorNight);
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static boolean checkBeforeLollipop(){
// if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) return true;
// else return false;
// }
// Path: nightowllib/src/main/java/com/asha/nightowllib/observer/OwlViewContext.java
import android.app.Activity;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.util.SparseArray;
import com.asha.nightowllib.R;
import com.asha.nightowllib.observer.impls.AdditionThemeObserver;
import com.asha.nightowllib.observer.impls.NavBarObserver;
import com.asha.nightowllib.observer.impls.StatusBarObserver;
import static com.asha.nightowllib.NightOwlUtil.checkBeforeLollipop;
package com.asha.nightowllib.observer;
/**
* Created by hzqiujiadi on 15/11/9.
* hzqiujiadi ashqalcn@gmail.com
*/
public class OwlViewContext {
private int mLastMode = -1;
private SparseArray<IOwlObserverWithId> observers;
public OwlViewContext() {
observers = new SparseArray<>();
}
public void registerObserver( IOwlObserverWithId owlObserver ){
observers.put(owlObserver.getObserverId(), owlObserver);
}
public void unregisterObserver( IOwlObserverWithId owlObserver ){
observers.delete(owlObserver.getObserverId());
}
public void notifyObserver(int mode, Activity activity){
if ( mode == mLastMode ) return;
mLastMode = mode;
int size = observers.size();
for (int i = 0; i < size; i++) {
IOwlObserverWithId owlObserver = observers.valueAt(i);
owlObserver.onSkinChange(mode, activity);
}
}
public void setupWithCurrentActivity(Activity activity){
Resources.Theme theme = activity.getTheme();
TypedArray a = theme.obtainStyledAttributes(R.styleable.NightOwl_Theme);
if (a != null) {
if ( !checkBeforeLollipop() ){
if ( a.hasValue(R.styleable.NightOwl_Theme_night_navigationBarColor) ) | registerObserver(new NavBarObserver(activity, a, R.styleable.NightOwl_Theme_night_navigationBarColor)); |
ashqal/NightOwl | nightowllib/src/main/java/com/asha/nightowllib/observer/OwlViewContext.java | // Path: nightowllib/src/main/java/com/asha/nightowllib/observer/impls/AdditionThemeObserver.java
// public class AdditionThemeObserver implements IOwlObserverWithId {
//
// private static final String TAG = "AdditionThemeObserver";
// private int mThemeDay;
// private int mThemeNight;
// public AdditionThemeObserver(int themeDay, int themeNight) {
// mThemeDay = themeDay;
// mThemeNight = themeNight;
// }
//
// @Override
// public int getObserverId() {
// return AdditionThemeObserver.this.hashCode();
// }
//
// @Override
// public void onSkinChange(int mode, Activity activity) {
// int theme = mode == 0 ? mThemeDay : mThemeNight;
// activity.getTheme().applyStyle(theme, true);
//
// //Log.e(TAG, String.format("%s %d", activity.getTheme(), theme));
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/observer/impls/NavBarObserver.java
// public class NavBarObserver implements IOwlObserverWithId {
// int mNavigationBarColor;
// int mNavigationBarColorNight;
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// public NavBarObserver(Activity activity, TypedArray a, int attr) {
// Window window = activity.getWindow();
// mNavigationBarColor = window.getNavigationBarColor();
// mNavigationBarColorNight = a.getColor(attr,mNavigationBarColor);
// }
//
// @Override
// public int getObserverId() {
// return NavBarObserver.this.hashCode();
// }
//
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// @Override
// public void onSkinChange(int mode, Activity activity) {
// activity.getWindow().setNavigationBarColor( mode == 0 ? mNavigationBarColor : mNavigationBarColorNight);
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/observer/impls/StatusBarObserver.java
// public class StatusBarObserver implements IOwlObserverWithId {
// int mStatusBarColor;
// int mStatusBarColorNight;
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// public StatusBarObserver(Activity activity, TypedArray a, int attr) {
// Window window = activity.getWindow();
// mStatusBarColor = window.getStatusBarColor();
// mStatusBarColorNight = a.getColor(attr,mStatusBarColorNight);
// }
//
// @Override
// public int getObserverId() {
// return StatusBarObserver.this.hashCode();
// }
//
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// @Override
// public void onSkinChange(int mode, Activity activity) {
// activity.getWindow().setStatusBarColor( mode == 0 ? mStatusBarColor : mStatusBarColorNight);
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static boolean checkBeforeLollipop(){
// if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) return true;
// else return false;
// }
| import android.app.Activity;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.util.SparseArray;
import com.asha.nightowllib.R;
import com.asha.nightowllib.observer.impls.AdditionThemeObserver;
import com.asha.nightowllib.observer.impls.NavBarObserver;
import com.asha.nightowllib.observer.impls.StatusBarObserver;
import static com.asha.nightowllib.NightOwlUtil.checkBeforeLollipop; | package com.asha.nightowllib.observer;
/**
* Created by hzqiujiadi on 15/11/9.
* hzqiujiadi ashqalcn@gmail.com
*/
public class OwlViewContext {
private int mLastMode = -1;
private SparseArray<IOwlObserverWithId> observers;
public OwlViewContext() {
observers = new SparseArray<>();
}
public void registerObserver( IOwlObserverWithId owlObserver ){
observers.put(owlObserver.getObserverId(), owlObserver);
}
public void unregisterObserver( IOwlObserverWithId owlObserver ){
observers.delete(owlObserver.getObserverId());
}
public void notifyObserver(int mode, Activity activity){
if ( mode == mLastMode ) return;
mLastMode = mode;
int size = observers.size();
for (int i = 0; i < size; i++) {
IOwlObserverWithId owlObserver = observers.valueAt(i);
owlObserver.onSkinChange(mode, activity);
}
}
public void setupWithCurrentActivity(Activity activity){
Resources.Theme theme = activity.getTheme();
TypedArray a = theme.obtainStyledAttributes(R.styleable.NightOwl_Theme);
if (a != null) {
if ( !checkBeforeLollipop() ){
if ( a.hasValue(R.styleable.NightOwl_Theme_night_navigationBarColor) )
registerObserver(new NavBarObserver(activity, a, R.styleable.NightOwl_Theme_night_navigationBarColor));
if ( a.hasValue(R.styleable.NightOwl_Theme_night_statusBarColor) ) | // Path: nightowllib/src/main/java/com/asha/nightowllib/observer/impls/AdditionThemeObserver.java
// public class AdditionThemeObserver implements IOwlObserverWithId {
//
// private static final String TAG = "AdditionThemeObserver";
// private int mThemeDay;
// private int mThemeNight;
// public AdditionThemeObserver(int themeDay, int themeNight) {
// mThemeDay = themeDay;
// mThemeNight = themeNight;
// }
//
// @Override
// public int getObserverId() {
// return AdditionThemeObserver.this.hashCode();
// }
//
// @Override
// public void onSkinChange(int mode, Activity activity) {
// int theme = mode == 0 ? mThemeDay : mThemeNight;
// activity.getTheme().applyStyle(theme, true);
//
// //Log.e(TAG, String.format("%s %d", activity.getTheme(), theme));
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/observer/impls/NavBarObserver.java
// public class NavBarObserver implements IOwlObserverWithId {
// int mNavigationBarColor;
// int mNavigationBarColorNight;
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// public NavBarObserver(Activity activity, TypedArray a, int attr) {
// Window window = activity.getWindow();
// mNavigationBarColor = window.getNavigationBarColor();
// mNavigationBarColorNight = a.getColor(attr,mNavigationBarColor);
// }
//
// @Override
// public int getObserverId() {
// return NavBarObserver.this.hashCode();
// }
//
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// @Override
// public void onSkinChange(int mode, Activity activity) {
// activity.getWindow().setNavigationBarColor( mode == 0 ? mNavigationBarColor : mNavigationBarColorNight);
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/observer/impls/StatusBarObserver.java
// public class StatusBarObserver implements IOwlObserverWithId {
// int mStatusBarColor;
// int mStatusBarColorNight;
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// public StatusBarObserver(Activity activity, TypedArray a, int attr) {
// Window window = activity.getWindow();
// mStatusBarColor = window.getStatusBarColor();
// mStatusBarColorNight = a.getColor(attr,mStatusBarColorNight);
// }
//
// @Override
// public int getObserverId() {
// return StatusBarObserver.this.hashCode();
// }
//
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// @Override
// public void onSkinChange(int mode, Activity activity) {
// activity.getWindow().setStatusBarColor( mode == 0 ? mStatusBarColor : mStatusBarColorNight);
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static boolean checkBeforeLollipop(){
// if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) return true;
// else return false;
// }
// Path: nightowllib/src/main/java/com/asha/nightowllib/observer/OwlViewContext.java
import android.app.Activity;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.util.SparseArray;
import com.asha.nightowllib.R;
import com.asha.nightowllib.observer.impls.AdditionThemeObserver;
import com.asha.nightowllib.observer.impls.NavBarObserver;
import com.asha.nightowllib.observer.impls.StatusBarObserver;
import static com.asha.nightowllib.NightOwlUtil.checkBeforeLollipop;
package com.asha.nightowllib.observer;
/**
* Created by hzqiujiadi on 15/11/9.
* hzqiujiadi ashqalcn@gmail.com
*/
public class OwlViewContext {
private int mLastMode = -1;
private SparseArray<IOwlObserverWithId> observers;
public OwlViewContext() {
observers = new SparseArray<>();
}
public void registerObserver( IOwlObserverWithId owlObserver ){
observers.put(owlObserver.getObserverId(), owlObserver);
}
public void unregisterObserver( IOwlObserverWithId owlObserver ){
observers.delete(owlObserver.getObserverId());
}
public void notifyObserver(int mode, Activity activity){
if ( mode == mLastMode ) return;
mLastMode = mode;
int size = observers.size();
for (int i = 0; i < size; i++) {
IOwlObserverWithId owlObserver = observers.valueAt(i);
owlObserver.onSkinChange(mode, activity);
}
}
public void setupWithCurrentActivity(Activity activity){
Resources.Theme theme = activity.getTheme();
TypedArray a = theme.obtainStyledAttributes(R.styleable.NightOwl_Theme);
if (a != null) {
if ( !checkBeforeLollipop() ){
if ( a.hasValue(R.styleable.NightOwl_Theme_night_navigationBarColor) )
registerObserver(new NavBarObserver(activity, a, R.styleable.NightOwl_Theme_night_navigationBarColor));
if ( a.hasValue(R.styleable.NightOwl_Theme_night_statusBarColor) ) | registerObserver(new StatusBarObserver(activity, a, R.styleable.NightOwl_Theme_night_statusBarColor)); |
ashqal/NightOwl | nightowllib/src/main/java/com/asha/nightowllib/observer/OwlViewContext.java | // Path: nightowllib/src/main/java/com/asha/nightowllib/observer/impls/AdditionThemeObserver.java
// public class AdditionThemeObserver implements IOwlObserverWithId {
//
// private static final String TAG = "AdditionThemeObserver";
// private int mThemeDay;
// private int mThemeNight;
// public AdditionThemeObserver(int themeDay, int themeNight) {
// mThemeDay = themeDay;
// mThemeNight = themeNight;
// }
//
// @Override
// public int getObserverId() {
// return AdditionThemeObserver.this.hashCode();
// }
//
// @Override
// public void onSkinChange(int mode, Activity activity) {
// int theme = mode == 0 ? mThemeDay : mThemeNight;
// activity.getTheme().applyStyle(theme, true);
//
// //Log.e(TAG, String.format("%s %d", activity.getTheme(), theme));
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/observer/impls/NavBarObserver.java
// public class NavBarObserver implements IOwlObserverWithId {
// int mNavigationBarColor;
// int mNavigationBarColorNight;
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// public NavBarObserver(Activity activity, TypedArray a, int attr) {
// Window window = activity.getWindow();
// mNavigationBarColor = window.getNavigationBarColor();
// mNavigationBarColorNight = a.getColor(attr,mNavigationBarColor);
// }
//
// @Override
// public int getObserverId() {
// return NavBarObserver.this.hashCode();
// }
//
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// @Override
// public void onSkinChange(int mode, Activity activity) {
// activity.getWindow().setNavigationBarColor( mode == 0 ? mNavigationBarColor : mNavigationBarColorNight);
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/observer/impls/StatusBarObserver.java
// public class StatusBarObserver implements IOwlObserverWithId {
// int mStatusBarColor;
// int mStatusBarColorNight;
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// public StatusBarObserver(Activity activity, TypedArray a, int attr) {
// Window window = activity.getWindow();
// mStatusBarColor = window.getStatusBarColor();
// mStatusBarColorNight = a.getColor(attr,mStatusBarColorNight);
// }
//
// @Override
// public int getObserverId() {
// return StatusBarObserver.this.hashCode();
// }
//
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// @Override
// public void onSkinChange(int mode, Activity activity) {
// activity.getWindow().setStatusBarColor( mode == 0 ? mStatusBarColor : mStatusBarColorNight);
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static boolean checkBeforeLollipop(){
// if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) return true;
// else return false;
// }
| import android.app.Activity;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.util.SparseArray;
import com.asha.nightowllib.R;
import com.asha.nightowllib.observer.impls.AdditionThemeObserver;
import com.asha.nightowllib.observer.impls.NavBarObserver;
import com.asha.nightowllib.observer.impls.StatusBarObserver;
import static com.asha.nightowllib.NightOwlUtil.checkBeforeLollipop; |
public void unregisterObserver( IOwlObserverWithId owlObserver ){
observers.delete(owlObserver.getObserverId());
}
public void notifyObserver(int mode, Activity activity){
if ( mode == mLastMode ) return;
mLastMode = mode;
int size = observers.size();
for (int i = 0; i < size; i++) {
IOwlObserverWithId owlObserver = observers.valueAt(i);
owlObserver.onSkinChange(mode, activity);
}
}
public void setupWithCurrentActivity(Activity activity){
Resources.Theme theme = activity.getTheme();
TypedArray a = theme.obtainStyledAttributes(R.styleable.NightOwl_Theme);
if (a != null) {
if ( !checkBeforeLollipop() ){
if ( a.hasValue(R.styleable.NightOwl_Theme_night_navigationBarColor) )
registerObserver(new NavBarObserver(activity, a, R.styleable.NightOwl_Theme_night_navigationBarColor));
if ( a.hasValue(R.styleable.NightOwl_Theme_night_statusBarColor) )
registerObserver(new StatusBarObserver(activity, a, R.styleable.NightOwl_Theme_night_statusBarColor));
}
if ( a.hasValue(R.styleable.NightOwl_Theme_night_additionThemeDay)
&& a.hasValue(R.styleable.NightOwl_Theme_night_additionThemeNight) ){
int themeDay = a.getResourceId(R.styleable.NightOwl_Theme_night_additionThemeDay,0 );
int themeNight = a.getResourceId(R.styleable.NightOwl_Theme_night_additionThemeNight,0 ); | // Path: nightowllib/src/main/java/com/asha/nightowllib/observer/impls/AdditionThemeObserver.java
// public class AdditionThemeObserver implements IOwlObserverWithId {
//
// private static final String TAG = "AdditionThemeObserver";
// private int mThemeDay;
// private int mThemeNight;
// public AdditionThemeObserver(int themeDay, int themeNight) {
// mThemeDay = themeDay;
// mThemeNight = themeNight;
// }
//
// @Override
// public int getObserverId() {
// return AdditionThemeObserver.this.hashCode();
// }
//
// @Override
// public void onSkinChange(int mode, Activity activity) {
// int theme = mode == 0 ? mThemeDay : mThemeNight;
// activity.getTheme().applyStyle(theme, true);
//
// //Log.e(TAG, String.format("%s %d", activity.getTheme(), theme));
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/observer/impls/NavBarObserver.java
// public class NavBarObserver implements IOwlObserverWithId {
// int mNavigationBarColor;
// int mNavigationBarColorNight;
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// public NavBarObserver(Activity activity, TypedArray a, int attr) {
// Window window = activity.getWindow();
// mNavigationBarColor = window.getNavigationBarColor();
// mNavigationBarColorNight = a.getColor(attr,mNavigationBarColor);
// }
//
// @Override
// public int getObserverId() {
// return NavBarObserver.this.hashCode();
// }
//
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// @Override
// public void onSkinChange(int mode, Activity activity) {
// activity.getWindow().setNavigationBarColor( mode == 0 ? mNavigationBarColor : mNavigationBarColorNight);
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/observer/impls/StatusBarObserver.java
// public class StatusBarObserver implements IOwlObserverWithId {
// int mStatusBarColor;
// int mStatusBarColorNight;
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// public StatusBarObserver(Activity activity, TypedArray a, int attr) {
// Window window = activity.getWindow();
// mStatusBarColor = window.getStatusBarColor();
// mStatusBarColorNight = a.getColor(attr,mStatusBarColorNight);
// }
//
// @Override
// public int getObserverId() {
// return StatusBarObserver.this.hashCode();
// }
//
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// @Override
// public void onSkinChange(int mode, Activity activity) {
// activity.getWindow().setStatusBarColor( mode == 0 ? mStatusBarColor : mStatusBarColorNight);
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static boolean checkBeforeLollipop(){
// if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) return true;
// else return false;
// }
// Path: nightowllib/src/main/java/com/asha/nightowllib/observer/OwlViewContext.java
import android.app.Activity;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.util.SparseArray;
import com.asha.nightowllib.R;
import com.asha.nightowllib.observer.impls.AdditionThemeObserver;
import com.asha.nightowllib.observer.impls.NavBarObserver;
import com.asha.nightowllib.observer.impls.StatusBarObserver;
import static com.asha.nightowllib.NightOwlUtil.checkBeforeLollipop;
public void unregisterObserver( IOwlObserverWithId owlObserver ){
observers.delete(owlObserver.getObserverId());
}
public void notifyObserver(int mode, Activity activity){
if ( mode == mLastMode ) return;
mLastMode = mode;
int size = observers.size();
for (int i = 0; i < size; i++) {
IOwlObserverWithId owlObserver = observers.valueAt(i);
owlObserver.onSkinChange(mode, activity);
}
}
public void setupWithCurrentActivity(Activity activity){
Resources.Theme theme = activity.getTheme();
TypedArray a = theme.obtainStyledAttributes(R.styleable.NightOwl_Theme);
if (a != null) {
if ( !checkBeforeLollipop() ){
if ( a.hasValue(R.styleable.NightOwl_Theme_night_navigationBarColor) )
registerObserver(new NavBarObserver(activity, a, R.styleable.NightOwl_Theme_night_navigationBarColor));
if ( a.hasValue(R.styleable.NightOwl_Theme_night_statusBarColor) )
registerObserver(new StatusBarObserver(activity, a, R.styleable.NightOwl_Theme_night_statusBarColor));
}
if ( a.hasValue(R.styleable.NightOwl_Theme_night_additionThemeDay)
&& a.hasValue(R.styleable.NightOwl_Theme_night_additionThemeNight) ){
int themeDay = a.getResourceId(R.styleable.NightOwl_Theme_night_additionThemeDay,0 );
int themeNight = a.getResourceId(R.styleable.NightOwl_Theme_night_additionThemeNight,0 ); | registerObserver(new AdditionThemeObserver(themeDay,themeNight)); |
ashqal/NightOwl | app/src/main/java/com/asha/nightowl/custom/OwlCustomTable.java | // Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlTable.java
// public class NightOwlTable {
// protected static void init(){
// registerHandler(ListViewHandler.class);
// registerHandler(ImageViewHandler.class);
// registerHandler(TextViewHandler.class);
// registerHandler(ButtonHandler.class);
// registerHandler(ViewHandler.class);
// }
//
// @OwlAttrScope(2000) public interface OwlView {
// @OwlStyleable int[] NightOwl_View = R.styleable.NightOwl_View;
// @OwlAttr(BackgroundPaint.class) int NightOwl_View_night_background = R.styleable.NightOwl_View_night_background;
// @OwlAttr(AlphaPaint.class) int NightOwl_View_night_alpha = R.styleable.NightOwl_View_night_alpha;
// }
//
// @OwlAttrScope(2100) public interface OwlTextView extends OwlView {
// @OwlStyleable int[] NightOwl_TextView = R.styleable.NightOwl_TextView;
// @OwlAttr(TextColorPaint.class) int NightOwl_TextView_night_textColor = R.styleable.NightOwl_TextView_night_textColor;
// @OwlAttr(TextColorPaint.class) int NightOwl_TextView_night_textColorHint = R.styleable.NightOwl_TextView_night_textColorHint;
// }
//
// @OwlAttrScope(2200) public interface OwlButton extends OwlTextView {
// }
//
// @OwlAttrScope(2300) public interface OwlImageView extends OwlView {
// @OwlStyleable int[] NightOwl_ImageView = R.styleable.NightOwl_ImageView;
// @OwlAttr(ImageViewSrcPaint.class) int NightOwl_ImageView_night_src = R.styleable.NightOwl_ImageView_night_src;
// }
//
// @OwlAttrScope(2400) public interface OwlListView extends OwlView {
// @OwlStyleable int[] NightOwl_ListView = R.styleable.NightOwl_ListView;
// @OwlAttr(ListViewDividerPaint.class) int NightOwl_ListView_night_divider = R.styleable.NightOwl_ListView_night_divider;
// @OwlAttr(ListViewSelectorPaint.class) int NightOwl_ListView_night_listSelector = R.styleable.NightOwl_ListView_night_listSelector;
// }
// }
| import com.asha.nightowl.R;
import com.asha.nightowllib.NightOwlTable;
import com.asha.nightowllib.handler.annotations.OwlAttr;
import com.asha.nightowllib.handler.annotations.OwlAttrScope;
import com.asha.nightowllib.handler.annotations.OwlStyleable; | package com.asha.nightowl.custom;
/**
* Created by hzqiujiadi on 15/11/11.
* hzqiujiadi ashqalcn@gmail.com
*/
public class OwlCustomTable {
public static final int TabLayoutScope = 10000; | // Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlTable.java
// public class NightOwlTable {
// protected static void init(){
// registerHandler(ListViewHandler.class);
// registerHandler(ImageViewHandler.class);
// registerHandler(TextViewHandler.class);
// registerHandler(ButtonHandler.class);
// registerHandler(ViewHandler.class);
// }
//
// @OwlAttrScope(2000) public interface OwlView {
// @OwlStyleable int[] NightOwl_View = R.styleable.NightOwl_View;
// @OwlAttr(BackgroundPaint.class) int NightOwl_View_night_background = R.styleable.NightOwl_View_night_background;
// @OwlAttr(AlphaPaint.class) int NightOwl_View_night_alpha = R.styleable.NightOwl_View_night_alpha;
// }
//
// @OwlAttrScope(2100) public interface OwlTextView extends OwlView {
// @OwlStyleable int[] NightOwl_TextView = R.styleable.NightOwl_TextView;
// @OwlAttr(TextColorPaint.class) int NightOwl_TextView_night_textColor = R.styleable.NightOwl_TextView_night_textColor;
// @OwlAttr(TextColorPaint.class) int NightOwl_TextView_night_textColorHint = R.styleable.NightOwl_TextView_night_textColorHint;
// }
//
// @OwlAttrScope(2200) public interface OwlButton extends OwlTextView {
// }
//
// @OwlAttrScope(2300) public interface OwlImageView extends OwlView {
// @OwlStyleable int[] NightOwl_ImageView = R.styleable.NightOwl_ImageView;
// @OwlAttr(ImageViewSrcPaint.class) int NightOwl_ImageView_night_src = R.styleable.NightOwl_ImageView_night_src;
// }
//
// @OwlAttrScope(2400) public interface OwlListView extends OwlView {
// @OwlStyleable int[] NightOwl_ListView = R.styleable.NightOwl_ListView;
// @OwlAttr(ListViewDividerPaint.class) int NightOwl_ListView_night_divider = R.styleable.NightOwl_ListView_night_divider;
// @OwlAttr(ListViewSelectorPaint.class) int NightOwl_ListView_night_listSelector = R.styleable.NightOwl_ListView_night_listSelector;
// }
// }
// Path: app/src/main/java/com/asha/nightowl/custom/OwlCustomTable.java
import com.asha.nightowl.R;
import com.asha.nightowllib.NightOwlTable;
import com.asha.nightowllib.handler.annotations.OwlAttr;
import com.asha.nightowllib.handler.annotations.OwlAttrScope;
import com.asha.nightowllib.handler.annotations.OwlStyleable;
package com.asha.nightowl.custom;
/**
* Created by hzqiujiadi on 15/11/11.
* hzqiujiadi ashqalcn@gmail.com
*/
public class OwlCustomTable {
public static final int TabLayoutScope = 10000; | @OwlAttrScope(TabLayoutScope) public interface OwlTabLayout extends NightOwlTable.OwlView { |
ashqal/NightOwl | nightowllib/src/main/java/com/asha/nightowllib/paint/OwlPaintManager.java | // Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlTable.java
// public class NightOwlTable {
// protected static void init(){
// registerHandler(ListViewHandler.class);
// registerHandler(ImageViewHandler.class);
// registerHandler(TextViewHandler.class);
// registerHandler(ButtonHandler.class);
// registerHandler(ViewHandler.class);
// }
//
// @OwlAttrScope(2000) public interface OwlView {
// @OwlStyleable int[] NightOwl_View = R.styleable.NightOwl_View;
// @OwlAttr(BackgroundPaint.class) int NightOwl_View_night_background = R.styleable.NightOwl_View_night_background;
// @OwlAttr(AlphaPaint.class) int NightOwl_View_night_alpha = R.styleable.NightOwl_View_night_alpha;
// }
//
// @OwlAttrScope(2100) public interface OwlTextView extends OwlView {
// @OwlStyleable int[] NightOwl_TextView = R.styleable.NightOwl_TextView;
// @OwlAttr(TextColorPaint.class) int NightOwl_TextView_night_textColor = R.styleable.NightOwl_TextView_night_textColor;
// @OwlAttr(TextColorPaint.class) int NightOwl_TextView_night_textColorHint = R.styleable.NightOwl_TextView_night_textColorHint;
// }
//
// @OwlAttrScope(2200) public interface OwlButton extends OwlTextView {
// }
//
// @OwlAttrScope(2300) public interface OwlImageView extends OwlView {
// @OwlStyleable int[] NightOwl_ImageView = R.styleable.NightOwl_ImageView;
// @OwlAttr(ImageViewSrcPaint.class) int NightOwl_ImageView_night_src = R.styleable.NightOwl_ImageView_night_src;
// }
//
// @OwlAttrScope(2400) public interface OwlListView extends OwlView {
// @OwlStyleable int[] NightOwl_ListView = R.styleable.NightOwl_ListView;
// @OwlAttr(ListViewDividerPaint.class) int NightOwl_ListView_night_divider = R.styleable.NightOwl_ListView_night_divider;
// @OwlAttr(ListViewSelectorPaint.class) int NightOwl_ListView_night_listSelector = R.styleable.NightOwl_ListView_night_listSelector;
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static int getStaticFieldIntSafely(Field field){
// try {
// return field.getInt(null);
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// return 0;
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static <T> T newInstanceSafely(Class<T> clz){
// try {
// return clz.newInstance();
// } catch (InstantiationException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// return null;
// }
| import android.util.SparseArray;
import com.asha.nightowllib.NightOwlTable;
import com.asha.nightowllib.handler.annotations.OwlAttr;
import com.asha.nightowllib.handler.annotations.OwlAttrScope;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
import static com.asha.nightowllib.NightOwlUtil.getStaticFieldIntSafely;
import static com.asha.nightowllib.NightOwlUtil.newInstanceSafely; | package com.asha.nightowllib.paint;
/**
* Created by hzqiujiadi on 15/11/8.
* hzqiujiadi ashqalcn@gmail.com
*/
public class OwlPaintManager {
private static final SparseArray<Class< ? extends IOwlPaint>> sPaints = new SparseArray<>();
private static final Map<Class< ? extends IOwlPaint>,IOwlPaint> sPaintInstances = new HashMap<>();
static {
// traverse all subclass. | // Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlTable.java
// public class NightOwlTable {
// protected static void init(){
// registerHandler(ListViewHandler.class);
// registerHandler(ImageViewHandler.class);
// registerHandler(TextViewHandler.class);
// registerHandler(ButtonHandler.class);
// registerHandler(ViewHandler.class);
// }
//
// @OwlAttrScope(2000) public interface OwlView {
// @OwlStyleable int[] NightOwl_View = R.styleable.NightOwl_View;
// @OwlAttr(BackgroundPaint.class) int NightOwl_View_night_background = R.styleable.NightOwl_View_night_background;
// @OwlAttr(AlphaPaint.class) int NightOwl_View_night_alpha = R.styleable.NightOwl_View_night_alpha;
// }
//
// @OwlAttrScope(2100) public interface OwlTextView extends OwlView {
// @OwlStyleable int[] NightOwl_TextView = R.styleable.NightOwl_TextView;
// @OwlAttr(TextColorPaint.class) int NightOwl_TextView_night_textColor = R.styleable.NightOwl_TextView_night_textColor;
// @OwlAttr(TextColorPaint.class) int NightOwl_TextView_night_textColorHint = R.styleable.NightOwl_TextView_night_textColorHint;
// }
//
// @OwlAttrScope(2200) public interface OwlButton extends OwlTextView {
// }
//
// @OwlAttrScope(2300) public interface OwlImageView extends OwlView {
// @OwlStyleable int[] NightOwl_ImageView = R.styleable.NightOwl_ImageView;
// @OwlAttr(ImageViewSrcPaint.class) int NightOwl_ImageView_night_src = R.styleable.NightOwl_ImageView_night_src;
// }
//
// @OwlAttrScope(2400) public interface OwlListView extends OwlView {
// @OwlStyleable int[] NightOwl_ListView = R.styleable.NightOwl_ListView;
// @OwlAttr(ListViewDividerPaint.class) int NightOwl_ListView_night_divider = R.styleable.NightOwl_ListView_night_divider;
// @OwlAttr(ListViewSelectorPaint.class) int NightOwl_ListView_night_listSelector = R.styleable.NightOwl_ListView_night_listSelector;
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static int getStaticFieldIntSafely(Field field){
// try {
// return field.getInt(null);
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// return 0;
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static <T> T newInstanceSafely(Class<T> clz){
// try {
// return clz.newInstance();
// } catch (InstantiationException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// return null;
// }
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/OwlPaintManager.java
import android.util.SparseArray;
import com.asha.nightowllib.NightOwlTable;
import com.asha.nightowllib.handler.annotations.OwlAttr;
import com.asha.nightowllib.handler.annotations.OwlAttrScope;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
import static com.asha.nightowllib.NightOwlUtil.getStaticFieldIntSafely;
import static com.asha.nightowllib.NightOwlUtil.newInstanceSafely;
package com.asha.nightowllib.paint;
/**
* Created by hzqiujiadi on 15/11/8.
* hzqiujiadi ashqalcn@gmail.com
*/
public class OwlPaintManager {
private static final SparseArray<Class< ? extends IOwlPaint>> sPaints = new SparseArray<>();
private static final Map<Class< ? extends IOwlPaint>,IOwlPaint> sPaintInstances = new HashMap<>();
static {
// traverse all subclass. | Class<?>[] classes = NightOwlTable.class.getDeclaredClasses(); |
ashqal/NightOwl | nightowllib/src/main/java/com/asha/nightowllib/paint/OwlPaintManager.java | // Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlTable.java
// public class NightOwlTable {
// protected static void init(){
// registerHandler(ListViewHandler.class);
// registerHandler(ImageViewHandler.class);
// registerHandler(TextViewHandler.class);
// registerHandler(ButtonHandler.class);
// registerHandler(ViewHandler.class);
// }
//
// @OwlAttrScope(2000) public interface OwlView {
// @OwlStyleable int[] NightOwl_View = R.styleable.NightOwl_View;
// @OwlAttr(BackgroundPaint.class) int NightOwl_View_night_background = R.styleable.NightOwl_View_night_background;
// @OwlAttr(AlphaPaint.class) int NightOwl_View_night_alpha = R.styleable.NightOwl_View_night_alpha;
// }
//
// @OwlAttrScope(2100) public interface OwlTextView extends OwlView {
// @OwlStyleable int[] NightOwl_TextView = R.styleable.NightOwl_TextView;
// @OwlAttr(TextColorPaint.class) int NightOwl_TextView_night_textColor = R.styleable.NightOwl_TextView_night_textColor;
// @OwlAttr(TextColorPaint.class) int NightOwl_TextView_night_textColorHint = R.styleable.NightOwl_TextView_night_textColorHint;
// }
//
// @OwlAttrScope(2200) public interface OwlButton extends OwlTextView {
// }
//
// @OwlAttrScope(2300) public interface OwlImageView extends OwlView {
// @OwlStyleable int[] NightOwl_ImageView = R.styleable.NightOwl_ImageView;
// @OwlAttr(ImageViewSrcPaint.class) int NightOwl_ImageView_night_src = R.styleable.NightOwl_ImageView_night_src;
// }
//
// @OwlAttrScope(2400) public interface OwlListView extends OwlView {
// @OwlStyleable int[] NightOwl_ListView = R.styleable.NightOwl_ListView;
// @OwlAttr(ListViewDividerPaint.class) int NightOwl_ListView_night_divider = R.styleable.NightOwl_ListView_night_divider;
// @OwlAttr(ListViewSelectorPaint.class) int NightOwl_ListView_night_listSelector = R.styleable.NightOwl_ListView_night_listSelector;
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static int getStaticFieldIntSafely(Field field){
// try {
// return field.getInt(null);
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// return 0;
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static <T> T newInstanceSafely(Class<T> clz){
// try {
// return clz.newInstance();
// } catch (InstantiationException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// return null;
// }
| import android.util.SparseArray;
import com.asha.nightowllib.NightOwlTable;
import com.asha.nightowllib.handler.annotations.OwlAttr;
import com.asha.nightowllib.handler.annotations.OwlAttrScope;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
import static com.asha.nightowllib.NightOwlUtil.getStaticFieldIntSafely;
import static com.asha.nightowllib.NightOwlUtil.newInstanceSafely; | package com.asha.nightowllib.paint;
/**
* Created by hzqiujiadi on 15/11/8.
* hzqiujiadi ashqalcn@gmail.com
*/
public class OwlPaintManager {
private static final SparseArray<Class< ? extends IOwlPaint>> sPaints = new SparseArray<>();
private static final Map<Class< ? extends IOwlPaint>,IOwlPaint> sPaintInstances = new HashMap<>();
static {
// traverse all subclass.
Class<?>[] classes = NightOwlTable.class.getDeclaredClasses();
for ( Class subClz : classes ){
registerPaint(subClz);
}
}
public static void registerPaint(Class subClz){
// look for all OwlAttrScope
OwlAttrScope owlAttrScope = (OwlAttrScope) subClz.getAnnotation(OwlAttrScope.class);
if ( owlAttrScope == null ) return;
int scope = owlAttrScope.value();
// traverse all declared fields in this subclass
Field[] fields = subClz.getDeclaredFields();
for (Field field : fields){
// look for all OwlAttr
OwlAttr attr = field.getAnnotation(OwlAttr.class);
if ( attr == null ) continue; | // Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlTable.java
// public class NightOwlTable {
// protected static void init(){
// registerHandler(ListViewHandler.class);
// registerHandler(ImageViewHandler.class);
// registerHandler(TextViewHandler.class);
// registerHandler(ButtonHandler.class);
// registerHandler(ViewHandler.class);
// }
//
// @OwlAttrScope(2000) public interface OwlView {
// @OwlStyleable int[] NightOwl_View = R.styleable.NightOwl_View;
// @OwlAttr(BackgroundPaint.class) int NightOwl_View_night_background = R.styleable.NightOwl_View_night_background;
// @OwlAttr(AlphaPaint.class) int NightOwl_View_night_alpha = R.styleable.NightOwl_View_night_alpha;
// }
//
// @OwlAttrScope(2100) public interface OwlTextView extends OwlView {
// @OwlStyleable int[] NightOwl_TextView = R.styleable.NightOwl_TextView;
// @OwlAttr(TextColorPaint.class) int NightOwl_TextView_night_textColor = R.styleable.NightOwl_TextView_night_textColor;
// @OwlAttr(TextColorPaint.class) int NightOwl_TextView_night_textColorHint = R.styleable.NightOwl_TextView_night_textColorHint;
// }
//
// @OwlAttrScope(2200) public interface OwlButton extends OwlTextView {
// }
//
// @OwlAttrScope(2300) public interface OwlImageView extends OwlView {
// @OwlStyleable int[] NightOwl_ImageView = R.styleable.NightOwl_ImageView;
// @OwlAttr(ImageViewSrcPaint.class) int NightOwl_ImageView_night_src = R.styleable.NightOwl_ImageView_night_src;
// }
//
// @OwlAttrScope(2400) public interface OwlListView extends OwlView {
// @OwlStyleable int[] NightOwl_ListView = R.styleable.NightOwl_ListView;
// @OwlAttr(ListViewDividerPaint.class) int NightOwl_ListView_night_divider = R.styleable.NightOwl_ListView_night_divider;
// @OwlAttr(ListViewSelectorPaint.class) int NightOwl_ListView_night_listSelector = R.styleable.NightOwl_ListView_night_listSelector;
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static int getStaticFieldIntSafely(Field field){
// try {
// return field.getInt(null);
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// return 0;
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static <T> T newInstanceSafely(Class<T> clz){
// try {
// return clz.newInstance();
// } catch (InstantiationException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// return null;
// }
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/OwlPaintManager.java
import android.util.SparseArray;
import com.asha.nightowllib.NightOwlTable;
import com.asha.nightowllib.handler.annotations.OwlAttr;
import com.asha.nightowllib.handler.annotations.OwlAttrScope;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
import static com.asha.nightowllib.NightOwlUtil.getStaticFieldIntSafely;
import static com.asha.nightowllib.NightOwlUtil.newInstanceSafely;
package com.asha.nightowllib.paint;
/**
* Created by hzqiujiadi on 15/11/8.
* hzqiujiadi ashqalcn@gmail.com
*/
public class OwlPaintManager {
private static final SparseArray<Class< ? extends IOwlPaint>> sPaints = new SparseArray<>();
private static final Map<Class< ? extends IOwlPaint>,IOwlPaint> sPaintInstances = new HashMap<>();
static {
// traverse all subclass.
Class<?>[] classes = NightOwlTable.class.getDeclaredClasses();
for ( Class subClz : classes ){
registerPaint(subClz);
}
}
public static void registerPaint(Class subClz){
// look for all OwlAttrScope
OwlAttrScope owlAttrScope = (OwlAttrScope) subClz.getAnnotation(OwlAttrScope.class);
if ( owlAttrScope == null ) return;
int scope = owlAttrScope.value();
// traverse all declared fields in this subclass
Field[] fields = subClz.getDeclaredFields();
for (Field field : fields){
// look for all OwlAttr
OwlAttr attr = field.getAnnotation(OwlAttr.class);
if ( attr == null ) continue; | int attrId = getStaticFieldIntSafely(field); |
ashqal/NightOwl | nightowllib/src/main/java/com/asha/nightowllib/paint/OwlPaintManager.java | // Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlTable.java
// public class NightOwlTable {
// protected static void init(){
// registerHandler(ListViewHandler.class);
// registerHandler(ImageViewHandler.class);
// registerHandler(TextViewHandler.class);
// registerHandler(ButtonHandler.class);
// registerHandler(ViewHandler.class);
// }
//
// @OwlAttrScope(2000) public interface OwlView {
// @OwlStyleable int[] NightOwl_View = R.styleable.NightOwl_View;
// @OwlAttr(BackgroundPaint.class) int NightOwl_View_night_background = R.styleable.NightOwl_View_night_background;
// @OwlAttr(AlphaPaint.class) int NightOwl_View_night_alpha = R.styleable.NightOwl_View_night_alpha;
// }
//
// @OwlAttrScope(2100) public interface OwlTextView extends OwlView {
// @OwlStyleable int[] NightOwl_TextView = R.styleable.NightOwl_TextView;
// @OwlAttr(TextColorPaint.class) int NightOwl_TextView_night_textColor = R.styleable.NightOwl_TextView_night_textColor;
// @OwlAttr(TextColorPaint.class) int NightOwl_TextView_night_textColorHint = R.styleable.NightOwl_TextView_night_textColorHint;
// }
//
// @OwlAttrScope(2200) public interface OwlButton extends OwlTextView {
// }
//
// @OwlAttrScope(2300) public interface OwlImageView extends OwlView {
// @OwlStyleable int[] NightOwl_ImageView = R.styleable.NightOwl_ImageView;
// @OwlAttr(ImageViewSrcPaint.class) int NightOwl_ImageView_night_src = R.styleable.NightOwl_ImageView_night_src;
// }
//
// @OwlAttrScope(2400) public interface OwlListView extends OwlView {
// @OwlStyleable int[] NightOwl_ListView = R.styleable.NightOwl_ListView;
// @OwlAttr(ListViewDividerPaint.class) int NightOwl_ListView_night_divider = R.styleable.NightOwl_ListView_night_divider;
// @OwlAttr(ListViewSelectorPaint.class) int NightOwl_ListView_night_listSelector = R.styleable.NightOwl_ListView_night_listSelector;
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static int getStaticFieldIntSafely(Field field){
// try {
// return field.getInt(null);
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// return 0;
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static <T> T newInstanceSafely(Class<T> clz){
// try {
// return clz.newInstance();
// } catch (InstantiationException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// return null;
// }
| import android.util.SparseArray;
import com.asha.nightowllib.NightOwlTable;
import com.asha.nightowllib.handler.annotations.OwlAttr;
import com.asha.nightowllib.handler.annotations.OwlAttrScope;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
import static com.asha.nightowllib.NightOwlUtil.getStaticFieldIntSafely;
import static com.asha.nightowllib.NightOwlUtil.newInstanceSafely; | package com.asha.nightowllib.paint;
/**
* Created by hzqiujiadi on 15/11/8.
* hzqiujiadi ashqalcn@gmail.com
*/
public class OwlPaintManager {
private static final SparseArray<Class< ? extends IOwlPaint>> sPaints = new SparseArray<>();
private static final Map<Class< ? extends IOwlPaint>,IOwlPaint> sPaintInstances = new HashMap<>();
static {
// traverse all subclass.
Class<?>[] classes = NightOwlTable.class.getDeclaredClasses();
for ( Class subClz : classes ){
registerPaint(subClz);
}
}
public static void registerPaint(Class subClz){
// look for all OwlAttrScope
OwlAttrScope owlAttrScope = (OwlAttrScope) subClz.getAnnotation(OwlAttrScope.class);
if ( owlAttrScope == null ) return;
int scope = owlAttrScope.value();
// traverse all declared fields in this subclass
Field[] fields = subClz.getDeclaredFields();
for (Field field : fields){
// look for all OwlAttr
OwlAttr attr = field.getAnnotation(OwlAttr.class);
if ( attr == null ) continue;
int attrId = getStaticFieldIntSafely(field);
Class< ? extends IOwlPaint> targetClz = attr.value();
sPaints.append( attrId + scope,targetClz );
}
}
public static IOwlPaint queryPaint(int attrWithScope){
Class< ? extends IOwlPaint> clz = sPaints.get(attrWithScope);
if ( clz == null ) return null;
IOwlPaint instance = sPaintInstances.get(clz);
if ( instance == null ){ | // Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlTable.java
// public class NightOwlTable {
// protected static void init(){
// registerHandler(ListViewHandler.class);
// registerHandler(ImageViewHandler.class);
// registerHandler(TextViewHandler.class);
// registerHandler(ButtonHandler.class);
// registerHandler(ViewHandler.class);
// }
//
// @OwlAttrScope(2000) public interface OwlView {
// @OwlStyleable int[] NightOwl_View = R.styleable.NightOwl_View;
// @OwlAttr(BackgroundPaint.class) int NightOwl_View_night_background = R.styleable.NightOwl_View_night_background;
// @OwlAttr(AlphaPaint.class) int NightOwl_View_night_alpha = R.styleable.NightOwl_View_night_alpha;
// }
//
// @OwlAttrScope(2100) public interface OwlTextView extends OwlView {
// @OwlStyleable int[] NightOwl_TextView = R.styleable.NightOwl_TextView;
// @OwlAttr(TextColorPaint.class) int NightOwl_TextView_night_textColor = R.styleable.NightOwl_TextView_night_textColor;
// @OwlAttr(TextColorPaint.class) int NightOwl_TextView_night_textColorHint = R.styleable.NightOwl_TextView_night_textColorHint;
// }
//
// @OwlAttrScope(2200) public interface OwlButton extends OwlTextView {
// }
//
// @OwlAttrScope(2300) public interface OwlImageView extends OwlView {
// @OwlStyleable int[] NightOwl_ImageView = R.styleable.NightOwl_ImageView;
// @OwlAttr(ImageViewSrcPaint.class) int NightOwl_ImageView_night_src = R.styleable.NightOwl_ImageView_night_src;
// }
//
// @OwlAttrScope(2400) public interface OwlListView extends OwlView {
// @OwlStyleable int[] NightOwl_ListView = R.styleable.NightOwl_ListView;
// @OwlAttr(ListViewDividerPaint.class) int NightOwl_ListView_night_divider = R.styleable.NightOwl_ListView_night_divider;
// @OwlAttr(ListViewSelectorPaint.class) int NightOwl_ListView_night_listSelector = R.styleable.NightOwl_ListView_night_listSelector;
// }
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static int getStaticFieldIntSafely(Field field){
// try {
// return field.getInt(null);
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// return 0;
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static <T> T newInstanceSafely(Class<T> clz){
// try {
// return clz.newInstance();
// } catch (InstantiationException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// return null;
// }
// Path: nightowllib/src/main/java/com/asha/nightowllib/paint/OwlPaintManager.java
import android.util.SparseArray;
import com.asha.nightowllib.NightOwlTable;
import com.asha.nightowllib.handler.annotations.OwlAttr;
import com.asha.nightowllib.handler.annotations.OwlAttrScope;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
import static com.asha.nightowllib.NightOwlUtil.getStaticFieldIntSafely;
import static com.asha.nightowllib.NightOwlUtil.newInstanceSafely;
package com.asha.nightowllib.paint;
/**
* Created by hzqiujiadi on 15/11/8.
* hzqiujiadi ashqalcn@gmail.com
*/
public class OwlPaintManager {
private static final SparseArray<Class< ? extends IOwlPaint>> sPaints = new SparseArray<>();
private static final Map<Class< ? extends IOwlPaint>,IOwlPaint> sPaintInstances = new HashMap<>();
static {
// traverse all subclass.
Class<?>[] classes = NightOwlTable.class.getDeclaredClasses();
for ( Class subClz : classes ){
registerPaint(subClz);
}
}
public static void registerPaint(Class subClz){
// look for all OwlAttrScope
OwlAttrScope owlAttrScope = (OwlAttrScope) subClz.getAnnotation(OwlAttrScope.class);
if ( owlAttrScope == null ) return;
int scope = owlAttrScope.value();
// traverse all declared fields in this subclass
Field[] fields = subClz.getDeclaredFields();
for (Field field : fields){
// look for all OwlAttr
OwlAttr attr = field.getAnnotation(OwlAttr.class);
if ( attr == null ) continue;
int attrId = getStaticFieldIntSafely(field);
Class< ? extends IOwlPaint> targetClz = attr.value();
sPaints.append( attrId + scope,targetClz );
}
}
public static IOwlPaint queryPaint(int attrWithScope){
Class< ? extends IOwlPaint> clz = sPaints.get(attrWithScope);
if ( clz == null ) return null;
IOwlPaint instance = sPaintInstances.get(clz);
if ( instance == null ){ | instance = newInstanceSafely(clz); |
ashqal/NightOwl | app/src/main/java/com/asha/nightowl/fragments/RecyclerViewFragment.java | // Path: app/src/main/java/com/asha/nightowl/DetailActivity.java
// public class DetailActivity extends AppCompatActivity {
//
// public static void launch(Context context){
// Intent i = new Intent(context,DetailActivity.class);
// context.startActivity(i);
// }
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// NightOwl.owlBeforeCreate(this);
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_detail);
// NightOwl.owlAfterCreate(this);
//
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
// if (getSupportActionBar() != null) getSupportActionBar().setDisplayShowHomeEnabled(true);
// }
//
// @Override
// protected void onResume() {
// super.onResume();
// NightOwl.owlResume(this);
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// switch (item.getItemId()){
// case android.R.id.home: this.finish(); return true;
// }
// return super.onOptionsItemSelected(item);
// }
// }
//
// Path: app/src/main/java/com/asha/nightowl/DemoUtil.java
// public static int fetchFakeImage(int positon){
//
// return FakeImage[positon % FakeImage.length];
// }
| import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.asha.nightowl.DetailActivity;
import com.asha.nightowl.R;
import static com.asha.nightowl.DemoUtil.fetchFakeImage; | return fragment;
}
public RecyclerViewFragment() {
}
RecyclerView recyclerView;
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(view.getContext()));
recyclerView.setAdapter(new DemoAdapter());
}
@Override
public void onResume() {
super.onResume();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_recycler_view, container, false);
}
public static class VH extends RecyclerView.ViewHolder{
ImageView mImageView;
public VH(View itemView) {
super(itemView);
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) { | // Path: app/src/main/java/com/asha/nightowl/DetailActivity.java
// public class DetailActivity extends AppCompatActivity {
//
// public static void launch(Context context){
// Intent i = new Intent(context,DetailActivity.class);
// context.startActivity(i);
// }
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// NightOwl.owlBeforeCreate(this);
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_detail);
// NightOwl.owlAfterCreate(this);
//
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
// if (getSupportActionBar() != null) getSupportActionBar().setDisplayShowHomeEnabled(true);
// }
//
// @Override
// protected void onResume() {
// super.onResume();
// NightOwl.owlResume(this);
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// switch (item.getItemId()){
// case android.R.id.home: this.finish(); return true;
// }
// return super.onOptionsItemSelected(item);
// }
// }
//
// Path: app/src/main/java/com/asha/nightowl/DemoUtil.java
// public static int fetchFakeImage(int positon){
//
// return FakeImage[positon % FakeImage.length];
// }
// Path: app/src/main/java/com/asha/nightowl/fragments/RecyclerViewFragment.java
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.asha.nightowl.DetailActivity;
import com.asha.nightowl.R;
import static com.asha.nightowl.DemoUtil.fetchFakeImage;
return fragment;
}
public RecyclerViewFragment() {
}
RecyclerView recyclerView;
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(view.getContext()));
recyclerView.setAdapter(new DemoAdapter());
}
@Override
public void onResume() {
super.onResume();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_recycler_view, container, false);
}
public static class VH extends RecyclerView.ViewHolder{
ImageView mImageView;
public VH(View itemView) {
super(itemView);
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) { | DetailActivity.launch(v.getContext()); |
ashqal/NightOwl | app/src/main/java/com/asha/nightowl/fragments/RecyclerViewFragment.java | // Path: app/src/main/java/com/asha/nightowl/DetailActivity.java
// public class DetailActivity extends AppCompatActivity {
//
// public static void launch(Context context){
// Intent i = new Intent(context,DetailActivity.class);
// context.startActivity(i);
// }
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// NightOwl.owlBeforeCreate(this);
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_detail);
// NightOwl.owlAfterCreate(this);
//
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
// if (getSupportActionBar() != null) getSupportActionBar().setDisplayShowHomeEnabled(true);
// }
//
// @Override
// protected void onResume() {
// super.onResume();
// NightOwl.owlResume(this);
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// switch (item.getItemId()){
// case android.R.id.home: this.finish(); return true;
// }
// return super.onOptionsItemSelected(item);
// }
// }
//
// Path: app/src/main/java/com/asha/nightowl/DemoUtil.java
// public static int fetchFakeImage(int positon){
//
// return FakeImage[positon % FakeImage.length];
// }
| import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.asha.nightowl.DetailActivity;
import com.asha.nightowl.R;
import static com.asha.nightowl.DemoUtil.fetchFakeImage; | @Override
public void onViewCreated(View view, Bundle savedInstanceState) {
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(view.getContext()));
recyclerView.setAdapter(new DemoAdapter());
}
@Override
public void onResume() {
super.onResume();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_recycler_view, container, false);
}
public static class VH extends RecyclerView.ViewHolder{
ImageView mImageView;
public VH(View itemView) {
super(itemView);
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DetailActivity.launch(v.getContext());
}
});
mImageView = (ImageView) itemView.findViewById(R.id.image);
}
public void bind(int position){ | // Path: app/src/main/java/com/asha/nightowl/DetailActivity.java
// public class DetailActivity extends AppCompatActivity {
//
// public static void launch(Context context){
// Intent i = new Intent(context,DetailActivity.class);
// context.startActivity(i);
// }
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// NightOwl.owlBeforeCreate(this);
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_detail);
// NightOwl.owlAfterCreate(this);
//
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
// if (getSupportActionBar() != null) getSupportActionBar().setDisplayShowHomeEnabled(true);
// }
//
// @Override
// protected void onResume() {
// super.onResume();
// NightOwl.owlResume(this);
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// switch (item.getItemId()){
// case android.R.id.home: this.finish(); return true;
// }
// return super.onOptionsItemSelected(item);
// }
// }
//
// Path: app/src/main/java/com/asha/nightowl/DemoUtil.java
// public static int fetchFakeImage(int positon){
//
// return FakeImage[positon % FakeImage.length];
// }
// Path: app/src/main/java/com/asha/nightowl/fragments/RecyclerViewFragment.java
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.asha.nightowl.DetailActivity;
import com.asha.nightowl.R;
import static com.asha.nightowl.DemoUtil.fetchFakeImage;
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(view.getContext()));
recyclerView.setAdapter(new DemoAdapter());
}
@Override
public void onResume() {
super.onResume();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_recycler_view, container, false);
}
public static class VH extends RecyclerView.ViewHolder{
ImageView mImageView;
public VH(View itemView) {
super(itemView);
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DetailActivity.launch(v.getContext());
}
});
mImageView = (ImageView) itemView.findViewById(R.id.image);
}
public void bind(int position){ | mImageView.setImageResource(fetchFakeImage(position)); |
ashqal/NightOwl | app/src/main/java/com/asha/nightowl/SettingActivity.java | // Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwl.java
// public class NightOwl {
// private static final String TAG = "NightOwl";
// private static final String WINDOW_INFLATER = "mLayoutInflater";
// private static final String THEME_INFLATER = "mInflater";
// private static NightOwl sInstance;
// static {
// NightOwlTable.init();
// }
//
// private int mMode = 0;
// private IOwlObserver mOwlObserver;
// private NightOwl(){
// }
//
// public static void owlBeforeCreate(Activity activity){
// Window window = activity.getWindow();
// LayoutInflater layoutInflater = window.getLayoutInflater();
//
// // replace the inflater in window
// LayoutInflater injectLayoutInflater1 = Factory4InjectedInflater.newInstance(layoutInflater, activity);
// injectLayoutInflater(injectLayoutInflater1
// , activity.getWindow()
// , activity.getWindow().getClass()
// , WINDOW_INFLATER);
//
// // replace the inflater in current ContextThemeWrapper
// LayoutInflater injectLayoutInflater2 = injectLayoutInflater1.cloneInContext(activity);
// injectLayoutInflater(injectLayoutInflater2
// , activity
// , ContextThemeWrapper.class
// , THEME_INFLATER);
//
// // insert owlViewContext into root view.
// View v = activity.getWindow().getDecorView();
// OwlViewContext owlObservable = new OwlViewContext();
// insertViewContext(v, owlObservable);
//
// }
//
//
// public static void owlAfterCreate(Activity activity){
// View root = activity.getWindow().getDecorView();
// OwlViewContext viewContext = obtainViewContext(root);
// checkNonNull(viewContext, "OwlViewContext can not be null!");
//
// // setup some observer
// viewContext.setupWithCurrentActivity(activity);
//
// // init set
// viewContext.notifyObserver(sharedInstance().mMode, activity);
// }
//
// public static void owlResume( Activity activity ){
// NightOwl nightOwl = sharedInstance();
// int targetMode = nightOwl.mMode;
//
// owlDressUp(targetMode, activity);
// }
//
// public static void owlNewDress( Activity activity ) {
// int current = owlCurrentMode() + 1;
// current %= 2;
//
// owlDressUp(current, activity);
// }
//
// public static void owlRecyclerFix(View view){
// int mode = owlCurrentMode();
// innerRefreshSkin(mode, view);
// }
//
// private static void owlDressUp( int mode, Activity activity ){
// // View tree
// NightOwl owl = sharedInstance();
// View root = activity.getWindow().getDecorView();
// OwlViewContext viewContext = obtainViewContext(root);
// checkNonNull(viewContext, "OwlViewContext can not be null!");
//
// if ( viewContext.needSync(mode) ){
// // refresh skin
// innerRefreshSkin(mode, root);
//
// // OwlObserver
// viewContext.notifyObserver(mode, activity);
// }
//
// owl.mMode = mode;
// if ( owl.mOwlObserver != null ) owl.mOwlObserver.onSkinChange(mode,activity);
// }
//
// /**
// * Register a custom view which created by new instance directly.
// *
// * @param view instanceof IOwlObserver & View
// * NightOwl will trigger view.onSkinChange immediately.
// */
// public static void owlRegisterCustom(IOwlObserver view){
// if ( view instanceof View ) {
// View target = (View) view;
// insertEmptyTag(target);
// view.onSkinChange(owlCurrentMode(), null);
// } else {
// throw new IllegalArgumentException("owlRegisterCustom param must be a instance of View");
// }
// }
//
// public static void owlRegisterHandler(Class<? extends ISkinHandler> clz, Class paintTable){
// OwlHandlerManager.registerHandler(clz);
// OwlPaintManager.registerPaint(paintTable);
// }
//
// public static int owlCurrentMode(){
// return sharedInstance().mMode;
// }
//
// private static void innerRefreshSkin(int mode, View view ){
// // refresh current view
// if ( checkViewCollected(view) ){
// ColorBox box = obtainSkinBox(view);
// if ( box != null ) box.refreshSkin(mode, view);
// if ( view instanceof IOwlObserver ){
// ((IOwlObserver) view).onSkinChange(mode,null);
// }
// }
// // traversal view tree
// if ( view instanceof ViewGroup){
// ViewGroup vg = (ViewGroup) view;
// View sub;
// for (int i = 0; i < vg.getChildCount(); i++) {
// sub = vg.getChildAt(i);
// innerRefreshSkin(mode, sub);
// }
// }
// }
//
// private static NightOwl sharedInstance(){
// checkNonNull(sInstance,"You must create NightOwl in Application onCreate.");
// return sInstance;
// }
//
// public static Builder builder(){
// return new Builder();
// }
//
// public static class Builder {
// private int mode;
// private IOwlObserver owlObserver;
// public Builder defaultMode(int mode){
// this.mode = mode;
// return this;
// }
//
// /**
// * Subscribed by a owlObserver to know the skin change.
// *
// * @param owlObserver do some persistent working here
// * @return Builder
// */
// public Builder subscribedBy(IOwlObserver owlObserver){
// this.owlObserver = owlObserver;
// return this;
// }
// public NightOwl create(){
// if ( sInstance != null ) throw new RuntimeException("Do not create NightOwl again.");
// sInstance = new NightOwl();
// sInstance.mMode = mode;
// sInstance.mOwlObserver = owlObserver;
// return sInstance;
// }
// }
// }
| import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import com.asha.nightowllib.NightOwl; | package com.asha.nightowl;
public class SettingActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) { | // Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwl.java
// public class NightOwl {
// private static final String TAG = "NightOwl";
// private static final String WINDOW_INFLATER = "mLayoutInflater";
// private static final String THEME_INFLATER = "mInflater";
// private static NightOwl sInstance;
// static {
// NightOwlTable.init();
// }
//
// private int mMode = 0;
// private IOwlObserver mOwlObserver;
// private NightOwl(){
// }
//
// public static void owlBeforeCreate(Activity activity){
// Window window = activity.getWindow();
// LayoutInflater layoutInflater = window.getLayoutInflater();
//
// // replace the inflater in window
// LayoutInflater injectLayoutInflater1 = Factory4InjectedInflater.newInstance(layoutInflater, activity);
// injectLayoutInflater(injectLayoutInflater1
// , activity.getWindow()
// , activity.getWindow().getClass()
// , WINDOW_INFLATER);
//
// // replace the inflater in current ContextThemeWrapper
// LayoutInflater injectLayoutInflater2 = injectLayoutInflater1.cloneInContext(activity);
// injectLayoutInflater(injectLayoutInflater2
// , activity
// , ContextThemeWrapper.class
// , THEME_INFLATER);
//
// // insert owlViewContext into root view.
// View v = activity.getWindow().getDecorView();
// OwlViewContext owlObservable = new OwlViewContext();
// insertViewContext(v, owlObservable);
//
// }
//
//
// public static void owlAfterCreate(Activity activity){
// View root = activity.getWindow().getDecorView();
// OwlViewContext viewContext = obtainViewContext(root);
// checkNonNull(viewContext, "OwlViewContext can not be null!");
//
// // setup some observer
// viewContext.setupWithCurrentActivity(activity);
//
// // init set
// viewContext.notifyObserver(sharedInstance().mMode, activity);
// }
//
// public static void owlResume( Activity activity ){
// NightOwl nightOwl = sharedInstance();
// int targetMode = nightOwl.mMode;
//
// owlDressUp(targetMode, activity);
// }
//
// public static void owlNewDress( Activity activity ) {
// int current = owlCurrentMode() + 1;
// current %= 2;
//
// owlDressUp(current, activity);
// }
//
// public static void owlRecyclerFix(View view){
// int mode = owlCurrentMode();
// innerRefreshSkin(mode, view);
// }
//
// private static void owlDressUp( int mode, Activity activity ){
// // View tree
// NightOwl owl = sharedInstance();
// View root = activity.getWindow().getDecorView();
// OwlViewContext viewContext = obtainViewContext(root);
// checkNonNull(viewContext, "OwlViewContext can not be null!");
//
// if ( viewContext.needSync(mode) ){
// // refresh skin
// innerRefreshSkin(mode, root);
//
// // OwlObserver
// viewContext.notifyObserver(mode, activity);
// }
//
// owl.mMode = mode;
// if ( owl.mOwlObserver != null ) owl.mOwlObserver.onSkinChange(mode,activity);
// }
//
// /**
// * Register a custom view which created by new instance directly.
// *
// * @param view instanceof IOwlObserver & View
// * NightOwl will trigger view.onSkinChange immediately.
// */
// public static void owlRegisterCustom(IOwlObserver view){
// if ( view instanceof View ) {
// View target = (View) view;
// insertEmptyTag(target);
// view.onSkinChange(owlCurrentMode(), null);
// } else {
// throw new IllegalArgumentException("owlRegisterCustom param must be a instance of View");
// }
// }
//
// public static void owlRegisterHandler(Class<? extends ISkinHandler> clz, Class paintTable){
// OwlHandlerManager.registerHandler(clz);
// OwlPaintManager.registerPaint(paintTable);
// }
//
// public static int owlCurrentMode(){
// return sharedInstance().mMode;
// }
//
// private static void innerRefreshSkin(int mode, View view ){
// // refresh current view
// if ( checkViewCollected(view) ){
// ColorBox box = obtainSkinBox(view);
// if ( box != null ) box.refreshSkin(mode, view);
// if ( view instanceof IOwlObserver ){
// ((IOwlObserver) view).onSkinChange(mode,null);
// }
// }
// // traversal view tree
// if ( view instanceof ViewGroup){
// ViewGroup vg = (ViewGroup) view;
// View sub;
// for (int i = 0; i < vg.getChildCount(); i++) {
// sub = vg.getChildAt(i);
// innerRefreshSkin(mode, sub);
// }
// }
// }
//
// private static NightOwl sharedInstance(){
// checkNonNull(sInstance,"You must create NightOwl in Application onCreate.");
// return sInstance;
// }
//
// public static Builder builder(){
// return new Builder();
// }
//
// public static class Builder {
// private int mode;
// private IOwlObserver owlObserver;
// public Builder defaultMode(int mode){
// this.mode = mode;
// return this;
// }
//
// /**
// * Subscribed by a owlObserver to know the skin change.
// *
// * @param owlObserver do some persistent working here
// * @return Builder
// */
// public Builder subscribedBy(IOwlObserver owlObserver){
// this.owlObserver = owlObserver;
// return this;
// }
// public NightOwl create(){
// if ( sInstance != null ) throw new RuntimeException("Do not create NightOwl again.");
// sInstance = new NightOwl();
// sInstance.mMode = mode;
// sInstance.mOwlObserver = owlObserver;
// return sInstance;
// }
// }
// }
// Path: app/src/main/java/com/asha/nightowl/SettingActivity.java
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import com.asha.nightowllib.NightOwl;
package com.asha.nightowl;
public class SettingActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) { | NightOwl.owlBeforeCreate(this); |
ashqal/NightOwl | nightowllib/src/main/java/com/asha/nightowllib/handler/impls/ButtonHandler.java | // Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlTable.java
// public class NightOwlTable {
// protected static void init(){
// registerHandler(ListViewHandler.class);
// registerHandler(ImageViewHandler.class);
// registerHandler(TextViewHandler.class);
// registerHandler(ButtonHandler.class);
// registerHandler(ViewHandler.class);
// }
//
// @OwlAttrScope(2000) public interface OwlView {
// @OwlStyleable int[] NightOwl_View = R.styleable.NightOwl_View;
// @OwlAttr(BackgroundPaint.class) int NightOwl_View_night_background = R.styleable.NightOwl_View_night_background;
// @OwlAttr(AlphaPaint.class) int NightOwl_View_night_alpha = R.styleable.NightOwl_View_night_alpha;
// }
//
// @OwlAttrScope(2100) public interface OwlTextView extends OwlView {
// @OwlStyleable int[] NightOwl_TextView = R.styleable.NightOwl_TextView;
// @OwlAttr(TextColorPaint.class) int NightOwl_TextView_night_textColor = R.styleable.NightOwl_TextView_night_textColor;
// @OwlAttr(TextColorPaint.class) int NightOwl_TextView_night_textColorHint = R.styleable.NightOwl_TextView_night_textColorHint;
// }
//
// @OwlAttrScope(2200) public interface OwlButton extends OwlTextView {
// }
//
// @OwlAttrScope(2300) public interface OwlImageView extends OwlView {
// @OwlStyleable int[] NightOwl_ImageView = R.styleable.NightOwl_ImageView;
// @OwlAttr(ImageViewSrcPaint.class) int NightOwl_ImageView_night_src = R.styleable.NightOwl_ImageView_night_src;
// }
//
// @OwlAttrScope(2400) public interface OwlListView extends OwlView {
// @OwlStyleable int[] NightOwl_ListView = R.styleable.NightOwl_ListView;
// @OwlAttr(ListViewDividerPaint.class) int NightOwl_ListView_night_divider = R.styleable.NightOwl_ListView_night_divider;
// @OwlAttr(ListViewSelectorPaint.class) int NightOwl_ListView_night_listSelector = R.styleable.NightOwl_ListView_night_listSelector;
// }
// }
| import android.widget.Button;
import com.asha.nightowllib.NightOwlTable;
import com.asha.nightowllib.handler.annotations.OwlHandle;
import com.asha.nightowllib.handler.annotations.OwlSysStyleable; | package com.asha.nightowllib.handler.impls;
/**
* Created by hzqiujiadi on 15/11/7.
* hzqiujiadi ashqalcn@gmail.com
*/
@OwlSysStyleable("textAppearance")
@OwlHandle(Button.class) | // Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlTable.java
// public class NightOwlTable {
// protected static void init(){
// registerHandler(ListViewHandler.class);
// registerHandler(ImageViewHandler.class);
// registerHandler(TextViewHandler.class);
// registerHandler(ButtonHandler.class);
// registerHandler(ViewHandler.class);
// }
//
// @OwlAttrScope(2000) public interface OwlView {
// @OwlStyleable int[] NightOwl_View = R.styleable.NightOwl_View;
// @OwlAttr(BackgroundPaint.class) int NightOwl_View_night_background = R.styleable.NightOwl_View_night_background;
// @OwlAttr(AlphaPaint.class) int NightOwl_View_night_alpha = R.styleable.NightOwl_View_night_alpha;
// }
//
// @OwlAttrScope(2100) public interface OwlTextView extends OwlView {
// @OwlStyleable int[] NightOwl_TextView = R.styleable.NightOwl_TextView;
// @OwlAttr(TextColorPaint.class) int NightOwl_TextView_night_textColor = R.styleable.NightOwl_TextView_night_textColor;
// @OwlAttr(TextColorPaint.class) int NightOwl_TextView_night_textColorHint = R.styleable.NightOwl_TextView_night_textColorHint;
// }
//
// @OwlAttrScope(2200) public interface OwlButton extends OwlTextView {
// }
//
// @OwlAttrScope(2300) public interface OwlImageView extends OwlView {
// @OwlStyleable int[] NightOwl_ImageView = R.styleable.NightOwl_ImageView;
// @OwlAttr(ImageViewSrcPaint.class) int NightOwl_ImageView_night_src = R.styleable.NightOwl_ImageView_night_src;
// }
//
// @OwlAttrScope(2400) public interface OwlListView extends OwlView {
// @OwlStyleable int[] NightOwl_ListView = R.styleable.NightOwl_ListView;
// @OwlAttr(ListViewDividerPaint.class) int NightOwl_ListView_night_divider = R.styleable.NightOwl_ListView_night_divider;
// @OwlAttr(ListViewSelectorPaint.class) int NightOwl_ListView_night_listSelector = R.styleable.NightOwl_ListView_night_listSelector;
// }
// }
// Path: nightowllib/src/main/java/com/asha/nightowllib/handler/impls/ButtonHandler.java
import android.widget.Button;
import com.asha.nightowllib.NightOwlTable;
import com.asha.nightowllib.handler.annotations.OwlHandle;
import com.asha.nightowllib.handler.annotations.OwlSysStyleable;
package com.asha.nightowllib.handler.impls;
/**
* Created by hzqiujiadi on 15/11/7.
* hzqiujiadi ashqalcn@gmail.com
*/
@OwlSysStyleable("textAppearance")
@OwlHandle(Button.class) | public class ButtonHandler extends AbsSkinHandler implements NightOwlTable.OwlButton { |
ashqal/NightOwl | nightowllib/src/main/java/com/asha/nightowllib/handler/OwlHandlerManager.java | // Path: nightowllib/src/main/java/com/asha/nightowllib/handler/ISkinHandler.java
// public interface ISkinHandler {
// void collect(int mode, View view, Context context, AttributeSet attrs);
// void onSkinChanged(int skin, View view);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static <T> T newInstanceSafely(Class<T> clz){
// try {
// return clz.newInstance();
// } catch (InstantiationException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// return null;
// }
| import android.view.View;
import com.asha.nightowllib.handler.ISkinHandler;
import com.asha.nightowllib.handler.annotations.OwlHandle;
import java.util.HashMap;
import static com.asha.nightowllib.NightOwlUtil.newInstanceSafely; | package com.asha.nightowllib.handler;
/**
* Created by hzqiujiadi on 15/11/8.
* hzqiujiadi ashqalcn@gmail.com
*/
public class OwlHandlerManager {
private static HashMap<Class,ISkinHandler> sHandlers = new HashMap<>();
private static HashMap<Class,Class<? extends ISkinHandler>> sHandlerTable = new HashMap<>();
// TODO: 15/11/5 impl it later.
private static Class<ISkinHandler> generateHandler() {
return null;
}
public static void registerView(Class<? extends View> clz){
sHandlerTable.put(clz, generateHandler());
}
public static void registerHandler(Class key, Class<? extends ISkinHandler> clz){
sHandlerTable.put(key,clz);
}
public static void registerHandler(Class<? extends ISkinHandler> clz){
OwlHandle owlHandle = clz.getAnnotation(OwlHandle.class);
if ( owlHandle != null ){
Class<? extends View>[] keys = owlHandle.value();
for ( Class<? extends View> key : keys )
registerHandler(key,clz);
}
}
public static ISkinHandler queryHandler(Class clz) {
Class<? extends ISkinHandler> handlerClz = sHandlerTable.get(clz);
// if handlerClz == null
// look for superclass's handlerClz
// it will be end when meet View.class
while( handlerClz == null ){
clz = clz.getSuperclass();
handlerClz = sHandlerTable.get(clz);
}
// query handler now
ISkinHandler skinHandler = sHandlers.get(handlerClz);
if ( skinHandler == null ) { | // Path: nightowllib/src/main/java/com/asha/nightowllib/handler/ISkinHandler.java
// public interface ISkinHandler {
// void collect(int mode, View view, Context context, AttributeSet attrs);
// void onSkinChanged(int skin, View view);
// }
//
// Path: nightowllib/src/main/java/com/asha/nightowllib/NightOwlUtil.java
// public static <T> T newInstanceSafely(Class<T> clz){
// try {
// return clz.newInstance();
// } catch (InstantiationException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// return null;
// }
// Path: nightowllib/src/main/java/com/asha/nightowllib/handler/OwlHandlerManager.java
import android.view.View;
import com.asha.nightowllib.handler.ISkinHandler;
import com.asha.nightowllib.handler.annotations.OwlHandle;
import java.util.HashMap;
import static com.asha.nightowllib.NightOwlUtil.newInstanceSafely;
package com.asha.nightowllib.handler;
/**
* Created by hzqiujiadi on 15/11/8.
* hzqiujiadi ashqalcn@gmail.com
*/
public class OwlHandlerManager {
private static HashMap<Class,ISkinHandler> sHandlers = new HashMap<>();
private static HashMap<Class,Class<? extends ISkinHandler>> sHandlerTable = new HashMap<>();
// TODO: 15/11/5 impl it later.
private static Class<ISkinHandler> generateHandler() {
return null;
}
public static void registerView(Class<? extends View> clz){
sHandlerTable.put(clz, generateHandler());
}
public static void registerHandler(Class key, Class<? extends ISkinHandler> clz){
sHandlerTable.put(key,clz);
}
public static void registerHandler(Class<? extends ISkinHandler> clz){
OwlHandle owlHandle = clz.getAnnotation(OwlHandle.class);
if ( owlHandle != null ){
Class<? extends View>[] keys = owlHandle.value();
for ( Class<? extends View> key : keys )
registerHandler(key,clz);
}
}
public static ISkinHandler queryHandler(Class clz) {
Class<? extends ISkinHandler> handlerClz = sHandlerTable.get(clz);
// if handlerClz == null
// look for superclass's handlerClz
// it will be end when meet View.class
while( handlerClz == null ){
clz = clz.getSuperclass();
handlerClz = sHandlerTable.get(clz);
}
// query handler now
ISkinHandler skinHandler = sHandlers.get(handlerClz);
if ( skinHandler == null ) { | skinHandler = newInstanceSafely(handlerClz); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.