Compare commits
10 Commits
master
...
develop_cp
Author | SHA1 | Date |
---|---|---|
chenpeng15 | e86007195c | |
chenpeng15 | 0ed3dfec40 | |
chenpeng15 | 87ac1e85b6 | |
chenpeng15 | a9876a6d0d | |
chenpeng15 | 27c6b85773 | |
chenpeng15 | 47afa24571 | |
chenpeng15 | a5f51968e7 | |
chenpeng15 | a1d63ffe48 | |
chenpeng15 | 22eb9a5430 | |
chenpeng15 | 4f6d354dce |
|
@ -1,42 +0,0 @@
|
|||
This is a brief introduce of our software program.
|
||||
|
||||
doc:项目开发过程中的文档类产品
|
||||
嗖藏.ReaderAdmin.DP.2.2.05 软件项目开发计划
|
||||
嗖藏.ReaderAdmin.RA.1.2.04 软件需求构想和描述
|
||||
嗖藏.ReaderAdmin.SS.3.2.07 软件需求规格说明书
|
||||
嗖藏.ReaderAdmin.DD.4.2.02 数据库组织结构详细设计
|
||||
嗖藏云笔记 软件工程实践自评表
|
||||
|
||||
|
||||
model:项目开发过程中生成的各种模型
|
||||
UML图:
|
||||
用例图(初步)
|
||||
用例图(最终)
|
||||
顺序图
|
||||
模型:
|
||||
嗖藏-编辑顺序图
|
||||
嗖藏-设计类图
|
||||
嗖藏-搜索顺序图
|
||||
嗖藏-一键收藏顺序图
|
||||
嗖藏-子系统类图
|
||||
嗖藏-子系统顺序图
|
||||
嗖藏-设计结构图
|
||||
软件体系结构:
|
||||
视图:
|
||||
嗖藏-开发视图(包图)
|
||||
嗖藏-逻辑视图
|
||||
嗖藏-思维导图
|
||||
嗖藏-物理视图(部署图)
|
||||
软件界面原型:
|
||||
嗖藏界面(一系列)
|
||||
嗖藏-界面类图
|
||||
嗖藏-界面流程图
|
||||
嗖藏-界面顺序图
|
||||
宣传展示:
|
||||
软件Logo
|
||||
嗖藏-项目展示
|
||||
宣传彩页
|
||||
|
||||
|
||||
src:开发项目的相关代码:
|
||||
MyApplication:因涉及文件过多具体不再向下细化
|
Before Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 310 KiB |
|
@ -1,731 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XPD:PROJECT xmlns:XPD="http://www.staruml.com" version="1">
|
||||
<XPD:HEADER>
|
||||
<XPD:SUBUNITS>
|
||||
</XPD:SUBUNITS>
|
||||
<XPD:PROFILES>
|
||||
</XPD:PROFILES>
|
||||
</XPD:HEADER>
|
||||
<XPD:BODY>
|
||||
<XPD:OBJ name="DocumentElement" type="UMLProject" guid="DHY4det1+0K1cr2oPEKRHwAA">
|
||||
<XPD:ATTR name="Title" type="string">Untitled</XPD:ATTR>
|
||||
<XPD:ATTR name="#OwnedElements" type="integer">2</XPD:ATTR>
|
||||
<XPD:OBJ name="OwnedElements[0]" type="UMLModel" guid="FEtNujumK0a6hExEQXPi+QAA">
|
||||
<XPD:ATTR name="Name" type="string">Model1</XPD:ATTR>
|
||||
<XPD:REF name="Namespace">DHY4det1+0K1cr2oPEKRHwAA</XPD:REF>
|
||||
<XPD:ATTR name="#OwnedCollaborationInstanceSets" type="integer">1</XPD:ATTR>
|
||||
<XPD:OBJ name="OwnedCollaborationInstanceSets[0]" type="UMLCollaborationInstanceSet" guid="pMrbrbFMGEG2uU8zhdwzGgAA">
|
||||
<XPD:ATTR name="Name" type="string">CollaborationInstanceSet1</XPD:ATTR>
|
||||
<XPD:REF name="RepresentedClassifier">FEtNujumK0a6hExEQXPi+QAA</XPD:REF>
|
||||
<XPD:ATTR name="#InteractionInstanceSets" type="integer">1</XPD:ATTR>
|
||||
<XPD:OBJ name="InteractionInstanceSets[0]" type="UMLInteractionInstanceSet" guid="F72aSmpDVUqnH/sc5Rx9cwAA">
|
||||
<XPD:ATTR name="Name" type="string">InteractionInstanceSet1</XPD:ATTR>
|
||||
<XPD:REF name="Context">pMrbrbFMGEG2uU8zhdwzGgAA</XPD:REF>
|
||||
<XPD:ATTR name="#OwnedFrames" type="integer">1</XPD:ATTR>
|
||||
<XPD:OBJ name="OwnedFrames[0]" type="UMLFrame" guid="PKofxpVCDUG80LjCVHzJcgAA">
|
||||
<XPD:ATTR name="Name" type="string">Frame1</XPD:ATTR>
|
||||
<XPD:ATTR name="FrameKind" type="string">sd</XPD:ATTR>
|
||||
<XPD:REF name="InteractionInstanceSet">F72aSmpDVUqnH/sc5Rx9cwAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
</XPD:OBJ>
|
||||
<XPD:ATTR name="#ParticipatingInstances" type="integer">3</XPD:ATTR>
|
||||
<XPD:OBJ name="ParticipatingInstances[0]" type="UMLObject" guid="J3E+GMlTmEmcq8T1qOnHJgAA">
|
||||
<XPD:ATTR name="Name" type="string">普通用户</XPD:ATTR>
|
||||
<XPD:REF name="CollaborationInstanceSet">pMrbrbFMGEG2uU8zhdwzGgAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="ParticipatingInstances[1]" type="UMLObject" guid="Pigu6orlRE6QZbtPXEHAXAAA">
|
||||
<XPD:ATTR name="Name" type="string">本地收藏文件夹</XPD:ATTR>
|
||||
<XPD:REF name="CollaborationInstanceSet">pMrbrbFMGEG2uU8zhdwzGgAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="ParticipatingInstances[2]" type="UMLObject" guid="xo7hSrSrSEOlICsWUHdk1QAA">
|
||||
<XPD:ATTR name="Name" type="string">云端数据</XPD:ATTR>
|
||||
<XPD:REF name="CollaborationInstanceSet">pMrbrbFMGEG2uU8zhdwzGgAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
</XPD:OBJ>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="OwnedElements[1]" type="UMLModel" guid="9kcuW4qjbE2oAXuXdzIhyAAA">
|
||||
<XPD:ATTR name="Name" type="string">Model2</XPD:ATTR>
|
||||
<XPD:REF name="Namespace">DHY4det1+0K1cr2oPEKRHwAA</XPD:REF>
|
||||
<XPD:ATTR name="#OwnedCollaborationInstanceSets" type="integer">1</XPD:ATTR>
|
||||
<XPD:OBJ name="OwnedCollaborationInstanceSets[0]" type="UMLCollaborationInstanceSet" guid="Vx+be2ry5USVYKqq7LYu2gAA">
|
||||
<XPD:ATTR name="Name" type="string">CollaborationInstanceSet1</XPD:ATTR>
|
||||
<XPD:REF name="RepresentedClassifier">9kcuW4qjbE2oAXuXdzIhyAAA</XPD:REF>
|
||||
<XPD:ATTR name="#InteractionInstanceSets" type="integer">1</XPD:ATTR>
|
||||
<XPD:OBJ name="InteractionInstanceSets[0]" type="UMLInteractionInstanceSet" guid="XBJkcPO3+kmQ2iSkxxMxcAAA">
|
||||
<XPD:ATTR name="Name" type="string">InteractionInstanceSet1</XPD:ATTR>
|
||||
<XPD:REF name="Context">Vx+be2ry5USVYKqq7LYu2gAA</XPD:REF>
|
||||
<XPD:ATTR name="#OwnedDiagrams" type="integer">1</XPD:ATTR>
|
||||
<XPD:OBJ name="OwnedDiagrams[0]" type="UMLSequenceDiagram" guid="vhr/WKpnb0m3MncscbvZHAAA">
|
||||
<XPD:ATTR name="Name" type="string">SequenceDiagram1</XPD:ATTR>
|
||||
<XPD:REF name="DiagramOwner">XBJkcPO3+kmQ2iSkxxMxcAAA</XPD:REF>
|
||||
<XPD:OBJ name="DiagramView" type="UMLSequenceDiagramView" guid="APbvW14E2EKkmEd6caN/1QAA">
|
||||
<XPD:REF name="Diagram">vhr/WKpnb0m3MncscbvZHAAA</XPD:REF>
|
||||
<XPD:ATTR name="#OwnedViews" type="integer">14</XPD:ATTR>
|
||||
<XPD:OBJ name="OwnedViews[0]" type="UMLSeqObjectView" guid="7GZ0hlhpMUCfBP+KDGCXsgAA">
|
||||
<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
|
||||
<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
|
||||
<XPD:ATTR name="Left" type="integer">104</XPD:ATTR>
|
||||
<XPD:ATTR name="Top" type="integer">44</XPD:ATTR>
|
||||
<XPD:ATTR name="Width" type="integer">70</XPD:ATTR>
|
||||
<XPD:ATTR name="Height" type="integer">413</XPD:ATTR>
|
||||
<XPD:REF name="Model">/HiuhruFCEG7kAjYsQnTeQAA</XPD:REF>
|
||||
<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="P21kUhNTPkGw8GMUcy4oSAAA">
|
||||
<XPD:OBJ name="NameLabel" type="LabelView" guid="6DEjdBNzBk2Uh7zASUlLmAAA">
|
||||
<XPD:ATTR name="FontStyle" type="integer">4</XPD:ATTR>
|
||||
<XPD:ATTR name="Text" type="string">用户</XPD:ATTR>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="2yk+4MOdVkqAlzOQCqmuOAAA">
|
||||
<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="PropertyLabel" type="LabelView" guid="Vzxy97twW06s0nEKpT59bQAA">
|
||||
<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
|
||||
</XPD:OBJ>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="LifeLine" type="UMLLifeLineView" guid="oTkAOfuwM0W5YS0EUl1dXAAA">
|
||||
<XPD:REF name="Model">/HiuhruFCEG7kAjYsQnTeQAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="OwnedViews[1]" type="UMLSeqObjectView" guid="v23XR4ozh0yH+Pt4jim5HQAA">
|
||||
<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
|
||||
<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
|
||||
<XPD:ATTR name="Left" type="integer">308</XPD:ATTR>
|
||||
<XPD:ATTR name="Top" type="integer">48</XPD:ATTR>
|
||||
<XPD:ATTR name="Width" type="integer">94</XPD:ATTR>
|
||||
<XPD:ATTR name="Height" type="integer">350</XPD:ATTR>
|
||||
<XPD:REF name="Model">mOQST0JPyEqniMnu9aXeHwAA</XPD:REF>
|
||||
<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="5O61Flr/60SJCSFuzGdHKgAA">
|
||||
<XPD:OBJ name="NameLabel" type="LabelView" guid="IIYQ1wBmhEq4eLykE90N9wAA">
|
||||
<XPD:ATTR name="FontStyle" type="integer">4</XPD:ATTR>
|
||||
<XPD:ATTR name="Text" type="string">本地收藏文件夹</XPD:ATTR>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="VTFpQyNv7EmnEM6qkL/EZgAA">
|
||||
<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="PropertyLabel" type="LabelView" guid="92Mx9K8hM0irnDgca+vBNAAA">
|
||||
<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
|
||||
</XPD:OBJ>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="LifeLine" type="UMLLifeLineView" guid="jpDsNmEk4EKGUzf9hPQBCgAA">
|
||||
<XPD:REF name="Model">mOQST0JPyEqniMnu9aXeHwAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="OwnedViews[2]" type="UMLSeqObjectView" guid="4iEjuV2CgUaND2SsXZgwdQAA">
|
||||
<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
|
||||
<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
|
||||
<XPD:ATTR name="Left" type="integer">516</XPD:ATTR>
|
||||
<XPD:ATTR name="Top" type="integer">44</XPD:ATTR>
|
||||
<XPD:ATTR name="Width" type="integer">70</XPD:ATTR>
|
||||
<XPD:ATTR name="Height" type="integer">350</XPD:ATTR>
|
||||
<XPD:REF name="Model">bt2vC7/ZqkKVz29G9ecPNwAA</XPD:REF>
|
||||
<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="LD+KmNYY90S2/JlIT2PccQAA">
|
||||
<XPD:OBJ name="NameLabel" type="LabelView" guid="yJhG0bF3Fk28qPAwr1p47gAA">
|
||||
<XPD:ATTR name="FontStyle" type="integer">4</XPD:ATTR>
|
||||
<XPD:ATTR name="Text" type="string">后台系统</XPD:ATTR>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="5BD1FsuC202cM4Zn38VuxgAA">
|
||||
<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="PropertyLabel" type="LabelView" guid="vri+3mANCkumZUeRPL1f9gAA">
|
||||
<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
|
||||
</XPD:OBJ>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="LifeLine" type="UMLLifeLineView" guid="2CQ/AvfQDUSMvAiuXz56VwAA">
|
||||
<XPD:REF name="Model">bt2vC7/ZqkKVz29G9ecPNwAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="OwnedViews[3]" type="UMLSeqObjectView" guid="rnnOoe3jUkiceXXaZTSMZgAA">
|
||||
<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
|
||||
<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
|
||||
<XPD:ATTR name="Left" type="integer">688</XPD:ATTR>
|
||||
<XPD:ATTR name="Top" type="integer">48</XPD:ATTR>
|
||||
<XPD:ATTR name="Width" type="integer">70</XPD:ATTR>
|
||||
<XPD:ATTR name="Height" type="integer">391</XPD:ATTR>
|
||||
<XPD:REF name="Model">oeDPkl6wUUCaalAsy+33hAAA</XPD:REF>
|
||||
<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="7QsIoQsBlkCmxzKgfRNrcAAA">
|
||||
<XPD:OBJ name="NameLabel" type="LabelView" guid="hc7Y6cXT8kKKFURlWNTWgwAA">
|
||||
<XPD:ATTR name="FontStyle" type="integer">4</XPD:ATTR>
|
||||
<XPD:ATTR name="Text" type="string">云端数据</XPD:ATTR>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="L4/GtIP3Xk2i/gPBrlUU3QAA">
|
||||
<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="PropertyLabel" type="LabelView" guid="sq0oHVS+ekuKQxAz+1wZ3gAA">
|
||||
<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
|
||||
</XPD:OBJ>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="LifeLine" type="UMLLifeLineView" guid="X161fkKfdEi0YWkvkw0HEQAA">
|
||||
<XPD:REF name="Model">oeDPkl6wUUCaalAsy+33hAAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="OwnedViews[4]" type="UMLSeqStimulusView" guid="LeD0outP/UC0k/sKZJyh/wAA">
|
||||
<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
|
||||
<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
|
||||
<XPD:ATTR name="LineStyle" type="LineStyleKind">lsRectilinear</XPD:ATTR>
|
||||
<XPD:ATTR name="Points" type="Points">139,96;348,96</XPD:ATTR>
|
||||
<XPD:REF name="Model">QqctX56sW0mp6peooQtHFAAA</XPD:REF>
|
||||
<XPD:REF name="Head">jpDsNmEk4EKGUzf9hPQBCgAA</XPD:REF>
|
||||
<XPD:REF name="Tail">oTkAOfuwM0W5YS0EUl1dXAAA</XPD:REF>
|
||||
<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="YYTq76c9OESZglIvPen7YgAA">
|
||||
<XPD:ATTR name="Alpha" type="real">1.5707963267949</XPD:ATTR>
|
||||
<XPD:ATTR name="Distance" type="real">10</XPD:ATTR>
|
||||
<XPD:ATTR name="Text" type="string">1 : 创建收藏()</XPD:ATTR>
|
||||
<XPD:REF name="Model">QqctX56sW0mp6peooQtHFAAA</XPD:REF>
|
||||
<XPD:REF name="HostEdge">LeD0outP/UC0k/sKZJyh/wAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="siTL1Ks6y0SIi/IHaScjKgAA">
|
||||
<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
|
||||
<XPD:ATTR name="Alpha" type="real">1.5707963267949</XPD:ATTR>
|
||||
<XPD:ATTR name="Distance" type="real">25</XPD:ATTR>
|
||||
<XPD:REF name="Model">QqctX56sW0mp6peooQtHFAAA</XPD:REF>
|
||||
<XPD:REF name="HostEdge">LeD0outP/UC0k/sKZJyh/wAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="TKA3a29BfkGTkjm+WdhovwAA">
|
||||
<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
|
||||
<XPD:ATTR name="Alpha" type="real">-1.5707963267949</XPD:ATTR>
|
||||
<XPD:ATTR name="Distance" type="real">10</XPD:ATTR>
|
||||
<XPD:REF name="Model">QqctX56sW0mp6peooQtHFAAA</XPD:REF>
|
||||
<XPD:REF name="HostEdge">LeD0outP/UC0k/sKZJyh/wAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="Activation" type="UMLActivationView" guid="WCFPuAeFJUOlHDmZBcl8fQAA">
|
||||
<XPD:ATTR name="Left" type="integer">348</XPD:ATTR>
|
||||
<XPD:ATTR name="Top" type="integer">96</XPD:ATTR>
|
||||
<XPD:ATTR name="Width" type="integer">14</XPD:ATTR>
|
||||
<XPD:ATTR name="Height" type="integer">69</XPD:ATTR>
|
||||
</XPD:OBJ>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="OwnedViews[5]" type="UMLSeqStimulusView" guid="wXJliSjI/02yAVx+i23TKgAA">
|
||||
<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
|
||||
<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
|
||||
<XPD:ATTR name="LineStyle" type="LineStyleKind">lsRectilinear</XPD:ATTR>
|
||||
<XPD:ATTR name="Points" type="Points">361,104;391,104;391,124;368,124</XPD:ATTR>
|
||||
<XPD:REF name="Model">RkVfGDvclkK+5u5hzY1YOgAA</XPD:REF>
|
||||
<XPD:REF name="Head">jpDsNmEk4EKGUzf9hPQBCgAA</XPD:REF>
|
||||
<XPD:REF name="Tail">jpDsNmEk4EKGUzf9hPQBCgAA</XPD:REF>
|
||||
<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="Tyn+QBCrbkupS5EX1CEalwAA">
|
||||
<XPD:ATTR name="Alpha" type="real">1.5707953267949</XPD:ATTR>
|
||||
<XPD:ATTR name="Distance" type="real">46</XPD:ATTR>
|
||||
<XPD:ATTR name="Text" type="string">2 : 按格式分类()</XPD:ATTR>
|
||||
<XPD:REF name="Model">RkVfGDvclkK+5u5hzY1YOgAA</XPD:REF>
|
||||
<XPD:REF name="HostEdge">wXJliSjI/02yAVx+i23TKgAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="EUO9I+R+V0yKXFEkQlNCtQAA">
|
||||
<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
|
||||
<XPD:ATTR name="Alpha" type="real">1.5707963267949</XPD:ATTR>
|
||||
<XPD:ATTR name="Distance" type="real">25</XPD:ATTR>
|
||||
<XPD:REF name="Model">RkVfGDvclkK+5u5hzY1YOgAA</XPD:REF>
|
||||
<XPD:REF name="HostEdge">wXJliSjI/02yAVx+i23TKgAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="4ju3U+Atyk2fGohiqU5pgwAA">
|
||||
<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
|
||||
<XPD:ATTR name="Alpha" type="real">-1.5707963267949</XPD:ATTR>
|
||||
<XPD:ATTR name="Distance" type="real">10</XPD:ATTR>
|
||||
<XPD:REF name="Model">RkVfGDvclkK+5u5hzY1YOgAA</XPD:REF>
|
||||
<XPD:REF name="HostEdge">wXJliSjI/02yAVx+i23TKgAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="Activation" type="UMLActivationView" guid="s0tv0pAtDUKCbkhmPgrz3AAA">
|
||||
<XPD:ATTR name="Left" type="integer">355</XPD:ATTR>
|
||||
<XPD:ATTR name="Top" type="integer">124</XPD:ATTR>
|
||||
<XPD:ATTR name="Width" type="integer">14</XPD:ATTR>
|
||||
<XPD:ATTR name="Height" type="integer">29</XPD:ATTR>
|
||||
</XPD:OBJ>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="OwnedViews[6]" type="UMLSeqStimulusView" guid="VnnsEJEKA0KcqBEBzVsElAAA">
|
||||
<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
|
||||
<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
|
||||
<XPD:ATTR name="LineStyle" type="LineStyleKind">lsRectilinear</XPD:ATTR>
|
||||
<XPD:ATTR name="Points" type="Points">361,156;544,156</XPD:ATTR>
|
||||
<XPD:REF name="Model">nFwqRbqLVUCz23pskbvFjgAA</XPD:REF>
|
||||
<XPD:REF name="Head">2CQ/AvfQDUSMvAiuXz56VwAA</XPD:REF>
|
||||
<XPD:REF name="Tail">jpDsNmEk4EKGUzf9hPQBCgAA</XPD:REF>
|
||||
<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="jyfgk6b8nUGz2Z+C0cAN4AAA">
|
||||
<XPD:ATTR name="Alpha" type="real">1.5707963267949</XPD:ATTR>
|
||||
<XPD:ATTR name="Distance" type="real">10</XPD:ATTR>
|
||||
<XPD:ATTR name="Text" type="string">3 : 上传()</XPD:ATTR>
|
||||
<XPD:REF name="Model">nFwqRbqLVUCz23pskbvFjgAA</XPD:REF>
|
||||
<XPD:REF name="HostEdge">VnnsEJEKA0KcqBEBzVsElAAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="r8oOBtzoqEyirvBOdg1fKQAA">
|
||||
<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
|
||||
<XPD:ATTR name="Alpha" type="real">1.5707963267949</XPD:ATTR>
|
||||
<XPD:ATTR name="Distance" type="real">25</XPD:ATTR>
|
||||
<XPD:REF name="Model">nFwqRbqLVUCz23pskbvFjgAA</XPD:REF>
|
||||
<XPD:REF name="HostEdge">VnnsEJEKA0KcqBEBzVsElAAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="7ws1RxrN7EOvF4CoXj/dbwAA">
|
||||
<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
|
||||
<XPD:ATTR name="Alpha" type="real">-1.5707963267949</XPD:ATTR>
|
||||
<XPD:ATTR name="Distance" type="real">10</XPD:ATTR>
|
||||
<XPD:REF name="Model">nFwqRbqLVUCz23pskbvFjgAA</XPD:REF>
|
||||
<XPD:REF name="HostEdge">VnnsEJEKA0KcqBEBzVsElAAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="Activation" type="UMLActivationView" guid="wFn7CPcCCk2TSiF6X11ftAAA">
|
||||
<XPD:ATTR name="Left" type="integer">544</XPD:ATTR>
|
||||
<XPD:ATTR name="Top" type="integer">156</XPD:ATTR>
|
||||
<XPD:ATTR name="Width" type="integer">14</XPD:ATTR>
|
||||
<XPD:ATTR name="Height" type="integer">29</XPD:ATTR>
|
||||
</XPD:OBJ>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="OwnedViews[7]" type="UMLSeqStimulusView" guid="xnHL3C7vI0CphC4MJGHKrQAA">
|
||||
<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
|
||||
<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
|
||||
<XPD:ATTR name="LineStyle" type="LineStyleKind">lsRectilinear</XPD:ATTR>
|
||||
<XPD:ATTR name="Points" type="Points">139,170;348,170</XPD:ATTR>
|
||||
<XPD:REF name="Model">Wz2Vr2hoN0u8tDU9IXDeggAA</XPD:REF>
|
||||
<XPD:REF name="Head">jpDsNmEk4EKGUzf9hPQBCgAA</XPD:REF>
|
||||
<XPD:REF name="Tail">oTkAOfuwM0W5YS0EUl1dXAAA</XPD:REF>
|
||||
<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="HYLNQp4Hw0iZ6PS1WC4GeAAA">
|
||||
<XPD:ATTR name="Alpha" type="real">1.5707963267949</XPD:ATTR>
|
||||
<XPD:ATTR name="Distance" type="real">10</XPD:ATTR>
|
||||
<XPD:ATTR name="Text" type="string">4 : 添加标签()</XPD:ATTR>
|
||||
<XPD:REF name="Model">Wz2Vr2hoN0u8tDU9IXDeggAA</XPD:REF>
|
||||
<XPD:REF name="HostEdge">xnHL3C7vI0CphC4MJGHKrQAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="Z8JIQm/ez0eV8gh4Wz4YugAA">
|
||||
<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
|
||||
<XPD:ATTR name="Alpha" type="real">1.5707963267949</XPD:ATTR>
|
||||
<XPD:ATTR name="Distance" type="real">25</XPD:ATTR>
|
||||
<XPD:REF name="Model">Wz2Vr2hoN0u8tDU9IXDeggAA</XPD:REF>
|
||||
<XPD:REF name="HostEdge">xnHL3C7vI0CphC4MJGHKrQAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="jhrLaJl3U0yoFLHpHy5QxwAA">
|
||||
<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
|
||||
<XPD:ATTR name="Alpha" type="real">-1.5707963267949</XPD:ATTR>
|
||||
<XPD:ATTR name="Distance" type="real">10</XPD:ATTR>
|
||||
<XPD:REF name="Model">Wz2Vr2hoN0u8tDU9IXDeggAA</XPD:REF>
|
||||
<XPD:REF name="HostEdge">xnHL3C7vI0CphC4MJGHKrQAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="Activation" type="UMLActivationView" guid="lCmX2Nu60E2ioZkL/5IrdQAA">
|
||||
<XPD:ATTR name="Left" type="integer">348</XPD:ATTR>
|
||||
<XPD:ATTR name="Top" type="integer">170</XPD:ATTR>
|
||||
<XPD:ATTR name="Width" type="integer">14</XPD:ATTR>
|
||||
<XPD:ATTR name="Height" type="integer">29</XPD:ATTR>
|
||||
</XPD:OBJ>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="OwnedViews[8]" type="UMLSeqStimulusView" guid="eBqe3KKJZU2cA0D7qZh+YwAA">
|
||||
<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
|
||||
<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
|
||||
<XPD:ATTR name="LineStyle" type="LineStyleKind">lsRectilinear</XPD:ATTR>
|
||||
<XPD:ATTR name="Points" type="Points">361,180;391,180;391,200;361,200</XPD:ATTR>
|
||||
<XPD:REF name="Model">Q+xZg3rTWEmCXclTYy+LKwAA</XPD:REF>
|
||||
<XPD:REF name="Head">jpDsNmEk4EKGUzf9hPQBCgAA</XPD:REF>
|
||||
<XPD:REF name="Tail">jpDsNmEk4EKGUzf9hPQBCgAA</XPD:REF>
|
||||
<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="uLBe797cgUaD/fBHiGVchAAA">
|
||||
<XPD:ATTR name="Alpha" type="real">1.5707953267949</XPD:ATTR>
|
||||
<XPD:ATTR name="Distance" type="real">58</XPD:ATTR>
|
||||
<XPD:ATTR name="Text" type="string">5 : 对标签进行修改()</XPD:ATTR>
|
||||
<XPD:REF name="Model">Q+xZg3rTWEmCXclTYy+LKwAA</XPD:REF>
|
||||
<XPD:REF name="HostEdge">eBqe3KKJZU2cA0D7qZh+YwAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="3CmG88BazkSyF9sqnjzYOAAA">
|
||||
<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
|
||||
<XPD:ATTR name="Alpha" type="real">1.5707963267949</XPD:ATTR>
|
||||
<XPD:ATTR name="Distance" type="real">25</XPD:ATTR>
|
||||
<XPD:REF name="Model">Q+xZg3rTWEmCXclTYy+LKwAA</XPD:REF>
|
||||
<XPD:REF name="HostEdge">eBqe3KKJZU2cA0D7qZh+YwAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="MnoB2twVakeAxoxYtQ5McQAA">
|
||||
<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
|
||||
<XPD:ATTR name="Alpha" type="real">-1.5707963267949</XPD:ATTR>
|
||||
<XPD:ATTR name="Distance" type="real">10</XPD:ATTR>
|
||||
<XPD:REF name="Model">Q+xZg3rTWEmCXclTYy+LKwAA</XPD:REF>
|
||||
<XPD:REF name="HostEdge">eBqe3KKJZU2cA0D7qZh+YwAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="Activation" type="UMLActivationView" guid="SjVL19W5gUGm46BAODThIwAA">
|
||||
<XPD:ATTR name="Left" type="integer">348</XPD:ATTR>
|
||||
<XPD:ATTR name="Top" type="integer">200</XPD:ATTR>
|
||||
<XPD:ATTR name="Width" type="integer">14</XPD:ATTR>
|
||||
<XPD:ATTR name="Height" type="integer">29</XPD:ATTR>
|
||||
</XPD:OBJ>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="OwnedViews[9]" type="UMLSeqStimulusView" guid="Ge5SypVUaEqoxWSrvg2SZAAA">
|
||||
<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
|
||||
<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
|
||||
<XPD:ATTR name="LineStyle" type="LineStyleKind">lsRectilinear</XPD:ATTR>
|
||||
<XPD:ATTR name="Points" type="Points">361,216;544,216</XPD:ATTR>
|
||||
<XPD:REF name="Model">TyQDeq+A6UGChjfCOfE74wAA</XPD:REF>
|
||||
<XPD:REF name="Head">2CQ/AvfQDUSMvAiuXz56VwAA</XPD:REF>
|
||||
<XPD:REF name="Tail">jpDsNmEk4EKGUzf9hPQBCgAA</XPD:REF>
|
||||
<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="qggqjERaBU+eeTNLcBogowAA">
|
||||
<XPD:ATTR name="Alpha" type="real">1.5707963267949</XPD:ATTR>
|
||||
<XPD:ATTR name="Distance" type="real">10</XPD:ATTR>
|
||||
<XPD:ATTR name="Text" type="string">6 : 上传()</XPD:ATTR>
|
||||
<XPD:REF name="Model">TyQDeq+A6UGChjfCOfE74wAA</XPD:REF>
|
||||
<XPD:REF name="HostEdge">Ge5SypVUaEqoxWSrvg2SZAAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="16PstG8Lw067gzCnnD89dgAA">
|
||||
<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
|
||||
<XPD:ATTR name="Alpha" type="real">1.5707963267949</XPD:ATTR>
|
||||
<XPD:ATTR name="Distance" type="real">25</XPD:ATTR>
|
||||
<XPD:REF name="Model">TyQDeq+A6UGChjfCOfE74wAA</XPD:REF>
|
||||
<XPD:REF name="HostEdge">Ge5SypVUaEqoxWSrvg2SZAAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="gEbLGHm/jEuBfcqp7wPvnwAA">
|
||||
<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
|
||||
<XPD:ATTR name="Alpha" type="real">-1.5707963267949</XPD:ATTR>
|
||||
<XPD:ATTR name="Distance" type="real">10</XPD:ATTR>
|
||||
<XPD:REF name="Model">TyQDeq+A6UGChjfCOfE74wAA</XPD:REF>
|
||||
<XPD:REF name="HostEdge">Ge5SypVUaEqoxWSrvg2SZAAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="Activation" type="UMLActivationView" guid="gZCzak9SaEyf5Ok/pnwpqQAA">
|
||||
<XPD:ATTR name="Left" type="integer">544</XPD:ATTR>
|
||||
<XPD:ATTR name="Top" type="integer">216</XPD:ATTR>
|
||||
<XPD:ATTR name="Width" type="integer">14</XPD:ATTR>
|
||||
<XPD:ATTR name="Height" type="integer">29</XPD:ATTR>
|
||||
</XPD:OBJ>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="OwnedViews[10]" type="UMLSeqStimulusView" guid="sVoqLWCufEymdpmMqT2LlgAA">
|
||||
<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
|
||||
<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
|
||||
<XPD:ATTR name="LineStyle" type="LineStyleKind">lsRectilinear</XPD:ATTR>
|
||||
<XPD:ATTR name="Points" type="Points">139,232;348,232</XPD:ATTR>
|
||||
<XPD:REF name="Model">DQmtlDlMtUKDTvpYge6/sAAA</XPD:REF>
|
||||
<XPD:REF name="Head">jpDsNmEk4EKGUzf9hPQBCgAA</XPD:REF>
|
||||
<XPD:REF name="Tail">oTkAOfuwM0W5YS0EUl1dXAAA</XPD:REF>
|
||||
<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="vix1XB+qPUm3KUesFa4y+QAA">
|
||||
<XPD:ATTR name="Alpha" type="real">1.5707963267949</XPD:ATTR>
|
||||
<XPD:ATTR name="Distance" type="real">10</XPD:ATTR>
|
||||
<XPD:ATTR name="Text" type="string">7 : 对标签进行操作(删除,移动等)()</XPD:ATTR>
|
||||
<XPD:REF name="Model">DQmtlDlMtUKDTvpYge6/sAAA</XPD:REF>
|
||||
<XPD:REF name="HostEdge">sVoqLWCufEymdpmMqT2LlgAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="aJAzWrSIHkab80gMePViBwAA">
|
||||
<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
|
||||
<XPD:ATTR name="Alpha" type="real">1.5707963267949</XPD:ATTR>
|
||||
<XPD:ATTR name="Distance" type="real">25</XPD:ATTR>
|
||||
<XPD:REF name="Model">DQmtlDlMtUKDTvpYge6/sAAA</XPD:REF>
|
||||
<XPD:REF name="HostEdge">sVoqLWCufEymdpmMqT2LlgAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="zfHLEcGoaUOf+9AJWsv43wAA">
|
||||
<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
|
||||
<XPD:ATTR name="Alpha" type="real">-1.5707963267949</XPD:ATTR>
|
||||
<XPD:ATTR name="Distance" type="real">10</XPD:ATTR>
|
||||
<XPD:REF name="Model">DQmtlDlMtUKDTvpYge6/sAAA</XPD:REF>
|
||||
<XPD:REF name="HostEdge">sVoqLWCufEymdpmMqT2LlgAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="Activation" type="UMLActivationView" guid="camR3b+AEEiNlf7swEgRmwAA">
|
||||
<XPD:ATTR name="Left" type="integer">348</XPD:ATTR>
|
||||
<XPD:ATTR name="Top" type="integer">232</XPD:ATTR>
|
||||
<XPD:ATTR name="Width" type="integer">14</XPD:ATTR>
|
||||
<XPD:ATTR name="Height" type="integer">29</XPD:ATTR>
|
||||
</XPD:OBJ>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="OwnedViews[11]" type="UMLSeqStimulusView" guid="DH6yIJoXe0azG5LEljeZNwAA">
|
||||
<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
|
||||
<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
|
||||
<XPD:ATTR name="LineStyle" type="LineStyleKind">lsRectilinear</XPD:ATTR>
|
||||
<XPD:ATTR name="Points" type="Points">355,264;716,264</XPD:ATTR>
|
||||
<XPD:REF name="Model">qPLBVnuG/kSurHoPmJ00NQAA</XPD:REF>
|
||||
<XPD:REF name="Head">X161fkKfdEi0YWkvkw0HEQAA</XPD:REF>
|
||||
<XPD:REF name="Tail">jpDsNmEk4EKGUzf9hPQBCgAA</XPD:REF>
|
||||
<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="ThJvIx1kkkePosLGTywPlQAA">
|
||||
<XPD:ATTR name="Alpha" type="real">1.5707963267949</XPD:ATTR>
|
||||
<XPD:ATTR name="Distance" type="real">10</XPD:ATTR>
|
||||
<XPD:ATTR name="Text" type="string">8 : 数据保存至云端()</XPD:ATTR>
|
||||
<XPD:REF name="Model">qPLBVnuG/kSurHoPmJ00NQAA</XPD:REF>
|
||||
<XPD:REF name="HostEdge">DH6yIJoXe0azG5LEljeZNwAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="MFsgMn+opUK1uNV//M5C1gAA">
|
||||
<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
|
||||
<XPD:ATTR name="Alpha" type="real">1.5707963267949</XPD:ATTR>
|
||||
<XPD:ATTR name="Distance" type="real">25</XPD:ATTR>
|
||||
<XPD:REF name="Model">qPLBVnuG/kSurHoPmJ00NQAA</XPD:REF>
|
||||
<XPD:REF name="HostEdge">DH6yIJoXe0azG5LEljeZNwAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="Ob5cnRv5pE+xjAK0YxN9AwAA">
|
||||
<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
|
||||
<XPD:ATTR name="Alpha" type="real">-1.5707963267949</XPD:ATTR>
|
||||
<XPD:ATTR name="Distance" type="real">10</XPD:ATTR>
|
||||
<XPD:REF name="Model">qPLBVnuG/kSurHoPmJ00NQAA</XPD:REF>
|
||||
<XPD:REF name="HostEdge">DH6yIJoXe0azG5LEljeZNwAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="Activation" type="UMLActivationView" guid="R5dgLL4TP0egRQeZe4MoMQAA">
|
||||
<XPD:ATTR name="Left" type="integer">716</XPD:ATTR>
|
||||
<XPD:ATTR name="Top" type="integer">264</XPD:ATTR>
|
||||
<XPD:ATTR name="Width" type="integer">14</XPD:ATTR>
|
||||
<XPD:ATTR name="Height" type="integer">29</XPD:ATTR>
|
||||
</XPD:OBJ>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="OwnedViews[12]" type="UMLSeqStimulusView" guid="oOQQOW2YcEGwa4t7oqef4gAA">
|
||||
<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
|
||||
<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
|
||||
<XPD:ATTR name="LineStyle" type="LineStyleKind">lsRectilinear</XPD:ATTR>
|
||||
<XPD:ATTR name="Points" type="Points">551,332;716,332</XPD:ATTR>
|
||||
<XPD:REF name="Model">wsYqsWjCD0qHOnZt5uoz/QAA</XPD:REF>
|
||||
<XPD:REF name="Head">X161fkKfdEi0YWkvkw0HEQAA</XPD:REF>
|
||||
<XPD:REF name="Tail">2CQ/AvfQDUSMvAiuXz56VwAA</XPD:REF>
|
||||
<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="K7l8JMM+9EqBzYN9gGYsMgAA">
|
||||
<XPD:ATTR name="Alpha" type="real">1.5707963267949</XPD:ATTR>
|
||||
<XPD:ATTR name="Distance" type="real">10</XPD:ATTR>
|
||||
<XPD:ATTR name="Text" type="string">9 : 数据保存至云端()</XPD:ATTR>
|
||||
<XPD:REF name="Model">wsYqsWjCD0qHOnZt5uoz/QAA</XPD:REF>
|
||||
<XPD:REF name="HostEdge">oOQQOW2YcEGwa4t7oqef4gAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="N+WFTHWgbUS/qoYDMXK07gAA">
|
||||
<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
|
||||
<XPD:ATTR name="Alpha" type="real">1.5707963267949</XPD:ATTR>
|
||||
<XPD:ATTR name="Distance" type="real">25</XPD:ATTR>
|
||||
<XPD:REF name="Model">wsYqsWjCD0qHOnZt5uoz/QAA</XPD:REF>
|
||||
<XPD:REF name="HostEdge">oOQQOW2YcEGwa4t7oqef4gAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="Duh9xNcle0uYL5/nbMdHHAAA">
|
||||
<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
|
||||
<XPD:ATTR name="Alpha" type="real">-1.5707963267949</XPD:ATTR>
|
||||
<XPD:ATTR name="Distance" type="real">10</XPD:ATTR>
|
||||
<XPD:REF name="Model">wsYqsWjCD0qHOnZt5uoz/QAA</XPD:REF>
|
||||
<XPD:REF name="HostEdge">oOQQOW2YcEGwa4t7oqef4gAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="Activation" type="UMLActivationView" guid="ggWMGzxvv06Yw+Mb2I6pcQAA">
|
||||
<XPD:ATTR name="Left" type="integer">716</XPD:ATTR>
|
||||
<XPD:ATTR name="Top" type="integer">332</XPD:ATTR>
|
||||
<XPD:ATTR name="Width" type="integer">14</XPD:ATTR>
|
||||
<XPD:ATTR name="Height" type="integer">29</XPD:ATTR>
|
||||
</XPD:OBJ>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="OwnedViews[13]" type="UMLSeqStimulusView" guid="5hDYsL07Ck2w3AKRYlZpQwAA">
|
||||
<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
|
||||
<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
|
||||
<XPD:ATTR name="LineStyle" type="LineStyleKind">lsRectilinear</XPD:ATTR>
|
||||
<XPD:ATTR name="Points" type="Points">723,370;145,370</XPD:ATTR>
|
||||
<XPD:REF name="Model">g0dSqKF8G0qvgPCOQb/BYAAA</XPD:REF>
|
||||
<XPD:REF name="Head">oTkAOfuwM0W5YS0EUl1dXAAA</XPD:REF>
|
||||
<XPD:REF name="Tail">X161fkKfdEi0YWkvkw0HEQAA</XPD:REF>
|
||||
<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="Qc4/IuxnA0iD7gaF5qWEWgAA">
|
||||
<XPD:ATTR name="Alpha" type="real">1.5707963267949</XPD:ATTR>
|
||||
<XPD:ATTR name="Distance" type="real">10</XPD:ATTR>
|
||||
<XPD:ATTR name="Text" type="string">10 : 返回结果()</XPD:ATTR>
|
||||
<XPD:REF name="Model">g0dSqKF8G0qvgPCOQb/BYAAA</XPD:REF>
|
||||
<XPD:REF name="HostEdge">5hDYsL07Ck2w3AKRYlZpQwAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="8G0mumMpsUqUONjIWyKG2QAA">
|
||||
<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
|
||||
<XPD:ATTR name="Alpha" type="real">1.5707963267949</XPD:ATTR>
|
||||
<XPD:ATTR name="Distance" type="real">25</XPD:ATTR>
|
||||
<XPD:REF name="Model">g0dSqKF8G0qvgPCOQb/BYAAA</XPD:REF>
|
||||
<XPD:REF name="HostEdge">5hDYsL07Ck2w3AKRYlZpQwAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="KJNw+f+6FEeFaSM0t51BoAAA">
|
||||
<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
|
||||
<XPD:ATTR name="Alpha" type="real">-1.5707963267949</XPD:ATTR>
|
||||
<XPD:ATTR name="Distance" type="real">10</XPD:ATTR>
|
||||
<XPD:REF name="Model">g0dSqKF8G0qvgPCOQb/BYAAA</XPD:REF>
|
||||
<XPD:REF name="HostEdge">5hDYsL07Ck2w3AKRYlZpQwAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="Activation" type="UMLActivationView" guid="aPr2nkdw10CZq4jTJ9bVcAAA">
|
||||
<XPD:ATTR name="Left" type="integer">132</XPD:ATTR>
|
||||
<XPD:ATTR name="Top" type="integer">370</XPD:ATTR>
|
||||
<XPD:ATTR name="Width" type="integer">14</XPD:ATTR>
|
||||
<XPD:ATTR name="Height" type="integer">29</XPD:ATTR>
|
||||
</XPD:OBJ>
|
||||
</XPD:OBJ>
|
||||
</XPD:OBJ>
|
||||
</XPD:OBJ>
|
||||
<XPD:ATTR name="#ParticipatingStimuli" type="integer">10</XPD:ATTR>
|
||||
<XPD:OBJ name="ParticipatingStimuli[0]" type="UMLStimulus" guid="QqctX56sW0mp6peooQtHFAAA">
|
||||
<XPD:ATTR name="Name" type="string">创建收藏</XPD:ATTR>
|
||||
<XPD:REF name="Sender">/HiuhruFCEG7kAjYsQnTeQAA</XPD:REF>
|
||||
<XPD:REF name="Receiver">mOQST0JPyEqniMnu9aXeHwAA</XPD:REF>
|
||||
<XPD:OBJ name="Action" type="UMLCallAction" guid="8YdgkWlKOke2h8vMpYvv+gAA">
|
||||
<XPD:REF name="Stimulus">QqctX56sW0mp6peooQtHFAAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:REF name="InteractionInstanceSet">XBJkcPO3+kmQ2iSkxxMxcAAA</XPD:REF>
|
||||
<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
|
||||
<XPD:REF name="Views[0]">LeD0outP/UC0k/sKZJyh/wAA</XPD:REF>
|
||||
<XPD:REF name="Views[1]">YYTq76c9OESZglIvPen7YgAA</XPD:REF>
|
||||
<XPD:REF name="Views[2]">siTL1Ks6y0SIi/IHaScjKgAA</XPD:REF>
|
||||
<XPD:REF name="Views[3]">TKA3a29BfkGTkjm+WdhovwAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="ParticipatingStimuli[1]" type="UMLStimulus" guid="RkVfGDvclkK+5u5hzY1YOgAA">
|
||||
<XPD:ATTR name="Name" type="string">按格式分类</XPD:ATTR>
|
||||
<XPD:REF name="Sender">mOQST0JPyEqniMnu9aXeHwAA</XPD:REF>
|
||||
<XPD:REF name="Receiver">mOQST0JPyEqniMnu9aXeHwAA</XPD:REF>
|
||||
<XPD:OBJ name="Action" type="UMLCallAction" guid="HB9u7+CorkW4u78sZWuxXQAA">
|
||||
<XPD:REF name="Stimulus">RkVfGDvclkK+5u5hzY1YOgAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:REF name="InteractionInstanceSet">XBJkcPO3+kmQ2iSkxxMxcAAA</XPD:REF>
|
||||
<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
|
||||
<XPD:REF name="Views[0]">wXJliSjI/02yAVx+i23TKgAA</XPD:REF>
|
||||
<XPD:REF name="Views[1]">Tyn+QBCrbkupS5EX1CEalwAA</XPD:REF>
|
||||
<XPD:REF name="Views[2]">EUO9I+R+V0yKXFEkQlNCtQAA</XPD:REF>
|
||||
<XPD:REF name="Views[3]">4ju3U+Atyk2fGohiqU5pgwAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="ParticipatingStimuli[2]" type="UMLStimulus" guid="nFwqRbqLVUCz23pskbvFjgAA">
|
||||
<XPD:ATTR name="Name" type="string">上传</XPD:ATTR>
|
||||
<XPD:REF name="Sender">mOQST0JPyEqniMnu9aXeHwAA</XPD:REF>
|
||||
<XPD:REF name="Receiver">bt2vC7/ZqkKVz29G9ecPNwAA</XPD:REF>
|
||||
<XPD:OBJ name="Action" type="UMLCallAction" guid="+nWSyzbI4UC4nJtiGt7nDwAA">
|
||||
<XPD:REF name="Stimulus">nFwqRbqLVUCz23pskbvFjgAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:REF name="InteractionInstanceSet">XBJkcPO3+kmQ2iSkxxMxcAAA</XPD:REF>
|
||||
<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
|
||||
<XPD:REF name="Views[0]">VnnsEJEKA0KcqBEBzVsElAAA</XPD:REF>
|
||||
<XPD:REF name="Views[1]">jyfgk6b8nUGz2Z+C0cAN4AAA</XPD:REF>
|
||||
<XPD:REF name="Views[2]">r8oOBtzoqEyirvBOdg1fKQAA</XPD:REF>
|
||||
<XPD:REF name="Views[3]">7ws1RxrN7EOvF4CoXj/dbwAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="ParticipatingStimuli[3]" type="UMLStimulus" guid="Wz2Vr2hoN0u8tDU9IXDeggAA">
|
||||
<XPD:ATTR name="Name" type="string">添加标签</XPD:ATTR>
|
||||
<XPD:REF name="Sender">/HiuhruFCEG7kAjYsQnTeQAA</XPD:REF>
|
||||
<XPD:REF name="Receiver">mOQST0JPyEqniMnu9aXeHwAA</XPD:REF>
|
||||
<XPD:OBJ name="Action" type="UMLCallAction" guid="FollmVfwz06eli9okZ5d3gAA">
|
||||
<XPD:REF name="Stimulus">Wz2Vr2hoN0u8tDU9IXDeggAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:REF name="InteractionInstanceSet">XBJkcPO3+kmQ2iSkxxMxcAAA</XPD:REF>
|
||||
<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
|
||||
<XPD:REF name="Views[0]">xnHL3C7vI0CphC4MJGHKrQAA</XPD:REF>
|
||||
<XPD:REF name="Views[1]">HYLNQp4Hw0iZ6PS1WC4GeAAA</XPD:REF>
|
||||
<XPD:REF name="Views[2]">Z8JIQm/ez0eV8gh4Wz4YugAA</XPD:REF>
|
||||
<XPD:REF name="Views[3]">jhrLaJl3U0yoFLHpHy5QxwAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="ParticipatingStimuli[4]" type="UMLStimulus" guid="Q+xZg3rTWEmCXclTYy+LKwAA">
|
||||
<XPD:ATTR name="Name" type="string">对标签进行修改</XPD:ATTR>
|
||||
<XPD:REF name="Sender">mOQST0JPyEqniMnu9aXeHwAA</XPD:REF>
|
||||
<XPD:REF name="Receiver">mOQST0JPyEqniMnu9aXeHwAA</XPD:REF>
|
||||
<XPD:OBJ name="Action" type="UMLCallAction" guid="hN7p1c4R4UG9GT5vzlwT7AAA">
|
||||
<XPD:REF name="Stimulus">Q+xZg3rTWEmCXclTYy+LKwAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:REF name="InteractionInstanceSet">XBJkcPO3+kmQ2iSkxxMxcAAA</XPD:REF>
|
||||
<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
|
||||
<XPD:REF name="Views[0]">eBqe3KKJZU2cA0D7qZh+YwAA</XPD:REF>
|
||||
<XPD:REF name="Views[1]">uLBe797cgUaD/fBHiGVchAAA</XPD:REF>
|
||||
<XPD:REF name="Views[2]">3CmG88BazkSyF9sqnjzYOAAA</XPD:REF>
|
||||
<XPD:REF name="Views[3]">MnoB2twVakeAxoxYtQ5McQAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="ParticipatingStimuli[5]" type="UMLStimulus" guid="TyQDeq+A6UGChjfCOfE74wAA">
|
||||
<XPD:ATTR name="Name" type="string">上传</XPD:ATTR>
|
||||
<XPD:REF name="Sender">mOQST0JPyEqniMnu9aXeHwAA</XPD:REF>
|
||||
<XPD:REF name="Receiver">bt2vC7/ZqkKVz29G9ecPNwAA</XPD:REF>
|
||||
<XPD:OBJ name="Action" type="UMLCallAction" guid="9EuSQcx5dky/k9VKqgvWcAAA">
|
||||
<XPD:REF name="Stimulus">TyQDeq+A6UGChjfCOfE74wAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:REF name="InteractionInstanceSet">XBJkcPO3+kmQ2iSkxxMxcAAA</XPD:REF>
|
||||
<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
|
||||
<XPD:REF name="Views[0]">Ge5SypVUaEqoxWSrvg2SZAAA</XPD:REF>
|
||||
<XPD:REF name="Views[1]">qggqjERaBU+eeTNLcBogowAA</XPD:REF>
|
||||
<XPD:REF name="Views[2]">16PstG8Lw067gzCnnD89dgAA</XPD:REF>
|
||||
<XPD:REF name="Views[3]">gEbLGHm/jEuBfcqp7wPvnwAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="ParticipatingStimuli[6]" type="UMLStimulus" guid="DQmtlDlMtUKDTvpYge6/sAAA">
|
||||
<XPD:ATTR name="Name" type="string">对标签进行操作(删除,移动等)</XPD:ATTR>
|
||||
<XPD:REF name="Sender">/HiuhruFCEG7kAjYsQnTeQAA</XPD:REF>
|
||||
<XPD:REF name="Receiver">mOQST0JPyEqniMnu9aXeHwAA</XPD:REF>
|
||||
<XPD:OBJ name="Action" type="UMLCallAction" guid="QfuzNUzdd0CpoL/dgpx/nQAA">
|
||||
<XPD:REF name="Stimulus">DQmtlDlMtUKDTvpYge6/sAAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:REF name="InteractionInstanceSet">XBJkcPO3+kmQ2iSkxxMxcAAA</XPD:REF>
|
||||
<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
|
||||
<XPD:REF name="Views[0]">sVoqLWCufEymdpmMqT2LlgAA</XPD:REF>
|
||||
<XPD:REF name="Views[1]">vix1XB+qPUm3KUesFa4y+QAA</XPD:REF>
|
||||
<XPD:REF name="Views[2]">aJAzWrSIHkab80gMePViBwAA</XPD:REF>
|
||||
<XPD:REF name="Views[3]">zfHLEcGoaUOf+9AJWsv43wAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="ParticipatingStimuli[7]" type="UMLStimulus" guid="qPLBVnuG/kSurHoPmJ00NQAA">
|
||||
<XPD:ATTR name="Name" type="string">数据保存至云端</XPD:ATTR>
|
||||
<XPD:REF name="Sender">mOQST0JPyEqniMnu9aXeHwAA</XPD:REF>
|
||||
<XPD:REF name="Receiver">oeDPkl6wUUCaalAsy+33hAAA</XPD:REF>
|
||||
<XPD:OBJ name="Action" type="UMLCallAction" guid="c+/hO0DxhkmdSHweathkdgAA">
|
||||
<XPD:REF name="Stimulus">qPLBVnuG/kSurHoPmJ00NQAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:REF name="InteractionInstanceSet">XBJkcPO3+kmQ2iSkxxMxcAAA</XPD:REF>
|
||||
<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
|
||||
<XPD:REF name="Views[0]">DH6yIJoXe0azG5LEljeZNwAA</XPD:REF>
|
||||
<XPD:REF name="Views[1]">ThJvIx1kkkePosLGTywPlQAA</XPD:REF>
|
||||
<XPD:REF name="Views[2]">MFsgMn+opUK1uNV//M5C1gAA</XPD:REF>
|
||||
<XPD:REF name="Views[3]">Ob5cnRv5pE+xjAK0YxN9AwAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="ParticipatingStimuli[8]" type="UMLStimulus" guid="wsYqsWjCD0qHOnZt5uoz/QAA">
|
||||
<XPD:ATTR name="Name" type="string">数据保存至云端</XPD:ATTR>
|
||||
<XPD:REF name="Sender">bt2vC7/ZqkKVz29G9ecPNwAA</XPD:REF>
|
||||
<XPD:REF name="Receiver">oeDPkl6wUUCaalAsy+33hAAA</XPD:REF>
|
||||
<XPD:OBJ name="Action" type="UMLCallAction" guid="kDY/UeajDE23SHs+TzQuNQAA">
|
||||
<XPD:REF name="Stimulus">wsYqsWjCD0qHOnZt5uoz/QAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:REF name="InteractionInstanceSet">XBJkcPO3+kmQ2iSkxxMxcAAA</XPD:REF>
|
||||
<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
|
||||
<XPD:REF name="Views[0]">oOQQOW2YcEGwa4t7oqef4gAA</XPD:REF>
|
||||
<XPD:REF name="Views[1]">K7l8JMM+9EqBzYN9gGYsMgAA</XPD:REF>
|
||||
<XPD:REF name="Views[2]">N+WFTHWgbUS/qoYDMXK07gAA</XPD:REF>
|
||||
<XPD:REF name="Views[3]">Duh9xNcle0uYL5/nbMdHHAAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="ParticipatingStimuli[9]" type="UMLStimulus" guid="g0dSqKF8G0qvgPCOQb/BYAAA">
|
||||
<XPD:ATTR name="Name" type="string">返回结果</XPD:ATTR>
|
||||
<XPD:REF name="Sender">oeDPkl6wUUCaalAsy+33hAAA</XPD:REF>
|
||||
<XPD:REF name="Receiver">/HiuhruFCEG7kAjYsQnTeQAA</XPD:REF>
|
||||
<XPD:OBJ name="Action" type="UMLCallAction" guid="MAYKHexVTEuZ6ZDGjn9ccQAA">
|
||||
<XPD:REF name="Stimulus">g0dSqKF8G0qvgPCOQb/BYAAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:REF name="InteractionInstanceSet">XBJkcPO3+kmQ2iSkxxMxcAAA</XPD:REF>
|
||||
<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
|
||||
<XPD:REF name="Views[0]">5hDYsL07Ck2w3AKRYlZpQwAA</XPD:REF>
|
||||
<XPD:REF name="Views[1]">Qc4/IuxnA0iD7gaF5qWEWgAA</XPD:REF>
|
||||
<XPD:REF name="Views[2]">8G0mumMpsUqUONjIWyKG2QAA</XPD:REF>
|
||||
<XPD:REF name="Views[3]">KJNw+f+6FEeFaSM0t51BoAAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:ATTR name="#OwnedFrames" type="integer">1</XPD:ATTR>
|
||||
<XPD:OBJ name="OwnedFrames[0]" type="UMLFrame" guid="JH/yV1mVEE6nlWvhAzsg6QAA">
|
||||
<XPD:ATTR name="Name" type="string">Frame1</XPD:ATTR>
|
||||
<XPD:ATTR name="FrameKind" type="string">sd</XPD:ATTR>
|
||||
<XPD:REF name="InteractionInstanceSet">XBJkcPO3+kmQ2iSkxxMxcAAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
</XPD:OBJ>
|
||||
<XPD:ATTR name="#ParticipatingInstances" type="integer">4</XPD:ATTR>
|
||||
<XPD:OBJ name="ParticipatingInstances[0]" type="UMLObject" guid="/HiuhruFCEG7kAjYsQnTeQAA">
|
||||
<XPD:ATTR name="Name" type="string">用户</XPD:ATTR>
|
||||
<XPD:REF name="CollaborationInstanceSet">Vx+be2ry5USVYKqq7LYu2gAA</XPD:REF>
|
||||
<XPD:ATTR name="#Views" type="integer">2</XPD:ATTR>
|
||||
<XPD:REF name="Views[0]">7GZ0hlhpMUCfBP+KDGCXsgAA</XPD:REF>
|
||||
<XPD:REF name="Views[1]">oTkAOfuwM0W5YS0EUl1dXAAA</XPD:REF>
|
||||
<XPD:ATTR name="#SendingStimuli" type="integer">3</XPD:ATTR>
|
||||
<XPD:REF name="SendingStimuli[0]">QqctX56sW0mp6peooQtHFAAA</XPD:REF>
|
||||
<XPD:REF name="SendingStimuli[1]">Wz2Vr2hoN0u8tDU9IXDeggAA</XPD:REF>
|
||||
<XPD:REF name="SendingStimuli[2]">DQmtlDlMtUKDTvpYge6/sAAA</XPD:REF>
|
||||
<XPD:ATTR name="#ReceivingStimuli" type="integer">1</XPD:ATTR>
|
||||
<XPD:REF name="ReceivingStimuli[0]">g0dSqKF8G0qvgPCOQb/BYAAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="ParticipatingInstances[1]" type="UMLObject" guid="mOQST0JPyEqniMnu9aXeHwAA">
|
||||
<XPD:ATTR name="Name" type="string">本地收藏文件夹</XPD:ATTR>
|
||||
<XPD:REF name="CollaborationInstanceSet">Vx+be2ry5USVYKqq7LYu2gAA</XPD:REF>
|
||||
<XPD:ATTR name="#Views" type="integer">2</XPD:ATTR>
|
||||
<XPD:REF name="Views[0]">v23XR4ozh0yH+Pt4jim5HQAA</XPD:REF>
|
||||
<XPD:REF name="Views[1]">jpDsNmEk4EKGUzf9hPQBCgAA</XPD:REF>
|
||||
<XPD:ATTR name="#SendingStimuli" type="integer">5</XPD:ATTR>
|
||||
<XPD:REF name="SendingStimuli[0]">RkVfGDvclkK+5u5hzY1YOgAA</XPD:REF>
|
||||
<XPD:REF name="SendingStimuli[1]">nFwqRbqLVUCz23pskbvFjgAA</XPD:REF>
|
||||
<XPD:REF name="SendingStimuli[2]">Q+xZg3rTWEmCXclTYy+LKwAA</XPD:REF>
|
||||
<XPD:REF name="SendingStimuli[3]">TyQDeq+A6UGChjfCOfE74wAA</XPD:REF>
|
||||
<XPD:REF name="SendingStimuli[4]">qPLBVnuG/kSurHoPmJ00NQAA</XPD:REF>
|
||||
<XPD:ATTR name="#ReceivingStimuli" type="integer">5</XPD:ATTR>
|
||||
<XPD:REF name="ReceivingStimuli[0]">QqctX56sW0mp6peooQtHFAAA</XPD:REF>
|
||||
<XPD:REF name="ReceivingStimuli[1]">RkVfGDvclkK+5u5hzY1YOgAA</XPD:REF>
|
||||
<XPD:REF name="ReceivingStimuli[2]">Wz2Vr2hoN0u8tDU9IXDeggAA</XPD:REF>
|
||||
<XPD:REF name="ReceivingStimuli[3]">Q+xZg3rTWEmCXclTYy+LKwAA</XPD:REF>
|
||||
<XPD:REF name="ReceivingStimuli[4]">DQmtlDlMtUKDTvpYge6/sAAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="ParticipatingInstances[2]" type="UMLObject" guid="bt2vC7/ZqkKVz29G9ecPNwAA">
|
||||
<XPD:ATTR name="Name" type="string">后台系统</XPD:ATTR>
|
||||
<XPD:REF name="CollaborationInstanceSet">Vx+be2ry5USVYKqq7LYu2gAA</XPD:REF>
|
||||
<XPD:ATTR name="#Views" type="integer">2</XPD:ATTR>
|
||||
<XPD:REF name="Views[0]">4iEjuV2CgUaND2SsXZgwdQAA</XPD:REF>
|
||||
<XPD:REF name="Views[1]">2CQ/AvfQDUSMvAiuXz56VwAA</XPD:REF>
|
||||
<XPD:ATTR name="#SendingStimuli" type="integer">1</XPD:ATTR>
|
||||
<XPD:REF name="SendingStimuli[0]">wsYqsWjCD0qHOnZt5uoz/QAA</XPD:REF>
|
||||
<XPD:ATTR name="#ReceivingStimuli" type="integer">2</XPD:ATTR>
|
||||
<XPD:REF name="ReceivingStimuli[0]">nFwqRbqLVUCz23pskbvFjgAA</XPD:REF>
|
||||
<XPD:REF name="ReceivingStimuli[1]">TyQDeq+A6UGChjfCOfE74wAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
<XPD:OBJ name="ParticipatingInstances[3]" type="UMLObject" guid="oeDPkl6wUUCaalAsy+33hAAA">
|
||||
<XPD:ATTR name="Name" type="string">云端数据</XPD:ATTR>
|
||||
<XPD:REF name="CollaborationInstanceSet">Vx+be2ry5USVYKqq7LYu2gAA</XPD:REF>
|
||||
<XPD:ATTR name="#Views" type="integer">2</XPD:ATTR>
|
||||
<XPD:REF name="Views[0]">rnnOoe3jUkiceXXaZTSMZgAA</XPD:REF>
|
||||
<XPD:REF name="Views[1]">X161fkKfdEi0YWkvkw0HEQAA</XPD:REF>
|
||||
<XPD:ATTR name="#SendingStimuli" type="integer">1</XPD:ATTR>
|
||||
<XPD:REF name="SendingStimuli[0]">g0dSqKF8G0qvgPCOQb/BYAAA</XPD:REF>
|
||||
<XPD:ATTR name="#ReceivingStimuli" type="integer">2</XPD:ATTR>
|
||||
<XPD:REF name="ReceivingStimuli[0]">qPLBVnuG/kSurHoPmJ00NQAA</XPD:REF>
|
||||
<XPD:REF name="ReceivingStimuli[1]">wsYqsWjCD0qHOnZt5uoz/QAA</XPD:REF>
|
||||
</XPD:OBJ>
|
||||
</XPD:OBJ>
|
||||
</XPD:OBJ>
|
||||
</XPD:OBJ>
|
||||
</XPD:BODY>
|
||||
</XPD:PROJECT>
|
Before Width: | Height: | Size: 239 KiB |
Before Width: | Height: | Size: 268 KiB |
Before Width: | Height: | Size: 60 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 36 KiB |
Before Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 37 KiB |
Before Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 61 KiB |
|
@ -1,9 +0,0 @@
|
|||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/workspace.xml
|
||||
/.idea/libraries
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
|
@ -1,22 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<resourceExtensions />
|
||||
<wildcardResourcePatterns>
|
||||
<entry name="!?*.java" />
|
||||
<entry name="!?*.form" />
|
||||
<entry name="!?*.class" />
|
||||
<entry name="!?*.groovy" />
|
||||
<entry name="!?*.scala" />
|
||||
<entry name="!?*.flex" />
|
||||
<entry name="!?*.kt" />
|
||||
<entry name="!?*.clj" />
|
||||
<entry name="!?*.aj" />
|
||||
</wildcardResourcePatterns>
|
||||
<annotationProcessing>
|
||||
<profile default="true" name="Default" enabled="false">
|
||||
<processorPath useClasspath="true" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
</project>
|
|
@ -1,3 +0,0 @@
|
|||
<component name="CopyrightManager">
|
||||
<settings default="" />
|
||||
</component>
|
|
@ -1,19 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
<option value="$PROJECT_DIR$/floatwindow" />
|
||||
</set>
|
||||
</option>
|
||||
<option name="resolveModulePerSourceSet" value="false" />
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
|
@ -1,46 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EntryPointsManager">
|
||||
<entry_points version="2.0" />
|
||||
</component>
|
||||
<component name="NullableNotNullManager">
|
||||
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
|
||||
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
|
||||
<option name="myNullables">
|
||||
<value>
|
||||
<list size="4">
|
||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
|
||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
|
||||
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
|
||||
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
<option name="myNotNulls">
|
||||
<value>
|
||||
<list size="4">
|
||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
|
||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
|
||||
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
|
||||
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
|
||||
<OptionsSetting value="true" id="Add" />
|
||||
<OptionsSetting value="true" id="Remove" />
|
||||
<OptionsSetting value="true" id="Checkout" />
|
||||
<OptionsSetting value="true" id="Update" />
|
||||
<OptionsSetting value="true" id="Status" />
|
||||
<OptionsSetting value="true" id="Edit" />
|
||||
<ConfirmationsSetting value="0" id="Add" />
|
||||
<ConfirmationsSetting value="0" id="Remove" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
</project>
|
|
@ -1,10 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/MyApplication.iml" filepath="$PROJECT_DIR$/MyApplication.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/floatwindow/floatwindow.iml" filepath="$PROJECT_DIR$/floatwindow/floatwindow.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
|
@ -1,12 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RunConfigurationProducerService">
|
||||
<option name="ignoredProducers">
|
||||
<set>
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
|
@ -1 +0,0 @@
|
|||
/build
|
|
@ -1,64 +0,0 @@
|
|||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'com.neenbedankt.android-apt'
|
||||
|
||||
android {
|
||||
compileSdkVersion 26
|
||||
buildToolsVersion "26.0.1"
|
||||
useLibrary 'org.apache.http.legacy'
|
||||
defaultConfig {
|
||||
applicationId "com.example.administrator.myapplication"
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 26
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
multiDexEnabled true
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
sourceSets {
|
||||
main() {
|
||||
jniLibs.srcDirs = ['libs']
|
||||
}
|
||||
|
||||
}
|
||||
lintOptions {
|
||||
ignoreWarnings true
|
||||
//lint 遇到 error 时继续 构建
|
||||
abortOnError false
|
||||
//build release 版本 时 开启lint 检测
|
||||
checkReleaseBuilds false
|
||||
// 防止在发布的时候出现因MissingTranslation导致Build Failed!
|
||||
disable 'MissingTranslation'
|
||||
}
|
||||
aaptOptions.cruncherEnabled = false
|
||||
aaptOptions.useNewCruncher = false
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(include: ['*.jar'], dir: 'libs')
|
||||
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
|
||||
exclude group: 'com.android.support', module: 'support-annotations'
|
||||
})
|
||||
compile project(':floatwindow')
|
||||
compile 'com.android.support:appcompat-v7:26.+'
|
||||
compile 'com.android.support.constraint:constraint-layout:1.0.2'
|
||||
compile 'com.jakewharton:butterknife:8.2.1'
|
||||
compile 'com.android.support:design:26.+'
|
||||
compile 'com.android.support:support-v4:26.+'
|
||||
compile 'com.android.support:support-vector-drawable:26.+'
|
||||
compile 'com.google.android.gms:play-services-appindexing:8.1.0'
|
||||
compile 'cn.bmob.android:http-legacy:1.0'
|
||||
compile 'cn.bmob.android:bmob-sdk:3.4.7-aar'
|
||||
compile 'org.greenrobot:eventbus:3.0.0'
|
||||
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.2'
|
||||
compile 'com.github.clans:fab:1.6.1'
|
||||
compile 'com.github.yhaolpz:FloatWindow:1.0.9'
|
||||
testCompile 'junit:junit:4.12'
|
||||
apt 'com.jakewharton:butterknife-compiler:8.2.1'
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in C:\Users\Administrator\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
|
@ -1,26 +0,0 @@
|
|||
package com.example.administrator.myapplication;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumentation test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() throws Exception {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getTargetContext();
|
||||
|
||||
assertEquals("com.example.administrator.myapplication", appContext.getPackageName());
|
||||
}
|
||||
}
|
|
@ -1,102 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.administrator.myapplication"
|
||||
android:versionCode="1"
|
||||
android:versionName="2.1.0">
|
||||
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
<!-- 获取悬浮窗的权限 -->
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<!-- 获取GSM(2g)、WCDMA(联通3g)等网络状态的信息 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<!-- 获取wifi网络状态的信息 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<!-- 允许读取手机状态 用于创建BmobInstallation -->
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
|
||||
|
||||
<!-- 获取sd卡写的权限,用于文件上传和下载 -->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<!-- UIL框架所需的权限 -->
|
||||
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
|
||||
<uses-permission android:name="android.permission.READ_LOGS" />
|
||||
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
|
||||
<application
|
||||
android:name=".app.BaseApplication"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/app_icon"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name=".ui.WelcomeActivity"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<!--
|
||||
ATTENTION: This was auto-generated to add Google Play services to your project for
|
||||
App Indexing. See https://g.co/AppIndexing/AndroidStudio for more information.
|
||||
-->
|
||||
<meta-data
|
||||
android:name="com.google.android.gms.version"
|
||||
android:value="@integer/google_play_services_version" />
|
||||
|
||||
<activity android:name=".ui.NoteEditActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
||||
<data android:mimeType="vnd.android.cursor.item/text_note" />
|
||||
<data android:mimeType="vnd.android.cursor.item/call_note" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".ui.SetLockActivity" />
|
||||
<activity
|
||||
android:name=".ui.MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name=".ui.UnLockActivity"
|
||||
android:theme="@style/AppTheme.NoActionBar"></activity>
|
||||
<activity
|
||||
android:name=".ui.LoginActivity"
|
||||
android:theme="@style/AppTheme.NoActionBar"></activity>
|
||||
<activity
|
||||
android:name=".ui.UserInfoActivity"
|
||||
android:theme="@style/AppTheme.NoActionBar"></activity>
|
||||
<activity
|
||||
android:name=".ui.RegisterActivity"
|
||||
android:theme="@style/AppTheme.NoActionBar"></activity>
|
||||
<activity
|
||||
android:name=".ui.AlarmAlertActivity"
|
||||
android:theme="@style/AppTheme.NoActionBar"></activity>
|
||||
|
||||
<provider
|
||||
android:name="android.support.v4.content.FileProvider"
|
||||
android:authorities="com.example.administrator.myapplication.provider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/provider_paths" />
|
||||
</provider>
|
||||
|
||||
<receiver
|
||||
android:name=".ui.NoteEditFragment$AlarmReceiver"
|
||||
android:process=":remote"></receiver>
|
||||
|
||||
<activity android:name=".ui.FloatWindowActivity"></activity>
|
||||
<activity android:name=".ui.NoteSearchActivity"></activity>
|
||||
<activity android:name=".ui.pic_view"></activity>
|
||||
</application>
|
||||
|
||||
</manifest> <!-- android:theme="@style/AppTheme.NoActionBar" -->
|
|
@ -1,91 +0,0 @@
|
|||
package com.example.administrator.myapplication.adapter;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
import com.example.administrator.myapplication.entity.BgPicEntity;
|
||||
import com.example.administrator.myapplication.utils.SystemUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class BgPicGridAdapter extends BaseAdapter {
|
||||
|
||||
|
||||
private List<BgPicEntity> bgList;
|
||||
private Resources resources;
|
||||
private Activity mActivity;
|
||||
private String mDefaultBgPath;
|
||||
private SystemUtils systemUtil;
|
||||
public BgPicGridAdapter(Activity mActivity,List<BgPicEntity> list)
|
||||
{
|
||||
this.bgList = list;
|
||||
this.mActivity=mActivity;
|
||||
this.resources = mActivity.getResources();
|
||||
systemUtil=new SystemUtils(mActivity);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
// TODO Auto-generated method stub
|
||||
return bgList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
// TODO Auto-generated method stub
|
||||
return bgList.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
// TODO Auto-generated method stub
|
||||
return position;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
// TODO Auto-generated method stub
|
||||
ViewHolder viewHolder;
|
||||
if (convertView == null) {
|
||||
viewHolder = new ViewHolder();
|
||||
convertView = LayoutInflater.from(mActivity).inflate(
|
||||
R.layout.bg_pic_grid_item, null);
|
||||
viewHolder.backgroundIv = (ImageView) convertView
|
||||
.findViewById(R.id.gridview_item_iv);
|
||||
viewHolder.checkedIv = (ImageView) convertView
|
||||
.findViewById(R.id.gridview_item_checked_iv);
|
||||
convertView.setTag(viewHolder);
|
||||
} else {
|
||||
viewHolder = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
viewHolder.backgroundIv.setBackgroundDrawable(new BitmapDrawable(
|
||||
resources, ((BgPicEntity)getItem(position)).bitmap));
|
||||
|
||||
mDefaultBgPath=systemUtil.getPath();
|
||||
if (((BgPicEntity)getItem(position)).path.equals(mDefaultBgPath)) {
|
||||
viewHolder.checkedIv.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
viewHolder.checkedIv.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
return convertView;
|
||||
|
||||
|
||||
}
|
||||
private class ViewHolder {
|
||||
ImageView checkedIv, backgroundIv;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,160 +0,0 @@
|
|||
package com.example.administrator.myapplication.adapter;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.provider.CalendarContract;
|
||||
import android.text.Html;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout.LayoutParams;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
import com.example.administrator.myapplication.entity.NotebookData;
|
||||
import com.example.administrator.myapplication.ui.NoteEditFragment;
|
||||
import com.example.administrator.myapplication.utils.SystemUtils;
|
||||
import com.example.administrator.myapplication.widget.HTQDragGridView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class NotebookAdapter extends BaseAdapter implements HTQDragGridView.DragGridBaseAdapter {
|
||||
private List<NotebookData> datas;
|
||||
private final Activity aty;
|
||||
private int currentHidePosition = -1;
|
||||
private final int width;
|
||||
private final int height;
|
||||
private boolean dataChange = false;
|
||||
|
||||
public NotebookAdapter(Activity aty, List<NotebookData> datas) {
|
||||
super();
|
||||
Collections.sort(datas);
|
||||
this.datas = datas;
|
||||
this.aty = aty;
|
||||
width = new SystemUtils(aty).getScreenW(aty) / 2;
|
||||
height = (int) aty.getResources().getDimension(R.dimen.space_35);
|
||||
}
|
||||
|
||||
public void refurbishData(List<NotebookData> datas) {
|
||||
if (datas == null) {
|
||||
datas = new ArrayList<NotebookData>(1);
|
||||
}
|
||||
Collections.sort(datas);
|
||||
this.datas = datas;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return datas.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return datas.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public List<NotebookData> getDatas() {
|
||||
return datas;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据是否发生了改变
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean getDataChange() {
|
||||
return dataChange;
|
||||
}
|
||||
|
||||
static class ViewHolder {
|
||||
TextView date;
|
||||
ImageView state;
|
||||
ImageView thumbtack;
|
||||
View titleBar;
|
||||
TextView content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View v, ViewGroup parent) {
|
||||
datas.get(position).setIid(position);
|
||||
NotebookData data = datas.get(position);
|
||||
|
||||
ViewHolder holder = null;
|
||||
if (v == null) {
|
||||
holder = new ViewHolder();
|
||||
v = View.inflate(aty, R.layout.item_notebook, null);
|
||||
holder.titleBar = v.findViewById(R.id.item_note_titlebar);
|
||||
holder.date = (TextView) v.findViewById(R.id.item_note_tv_date);
|
||||
holder.state = (ImageView) v.findViewById(R.id.item_note_img_state);
|
||||
holder.thumbtack = (ImageView) v
|
||||
.findViewById(R.id.item_note_img_thumbtack);
|
||||
holder.content = (TextView) v.findViewById(R.id.item_note_content);
|
||||
v.setTag(holder);
|
||||
} else {
|
||||
holder = (ViewHolder) v.getTag();
|
||||
}
|
||||
LayoutParams params = (LayoutParams) holder.content
|
||||
.getLayoutParams();
|
||||
params.width = width;
|
||||
params.height = (params.width - height);
|
||||
holder.content.setLayoutParams(params);
|
||||
|
||||
holder.titleBar
|
||||
.setBackgroundColor(NoteEditFragment.sTitleBackGrounds[data
|
||||
.getColor()]);
|
||||
holder.date.setText(data.getDate());
|
||||
if (data.getId() > 0) {
|
||||
holder.state.setVisibility(View.GONE);
|
||||
} else {
|
||||
holder.state.setVisibility(View.VISIBLE);
|
||||
}
|
||||
holder.thumbtack.setImageResource(NoteEditFragment.sThumbtackImgs[data
|
||||
.getColor()]);
|
||||
holder.content.setText(Html.fromHtml(data.getContent()));
|
||||
holder.content.setBackgroundColor(NoteEditFragment.sBackGrounds[data
|
||||
.getColor()]);
|
||||
if (position == currentHidePosition) {
|
||||
v.setVisibility(View.GONE);
|
||||
} else {
|
||||
v.setVisibility(View.VISIBLE);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reorderItems(int oldPosition, int newPosition) {
|
||||
dataChange = true;
|
||||
if (oldPosition >= datas.size() || oldPosition < 0) {
|
||||
return;
|
||||
}
|
||||
NotebookData temp = datas.get(oldPosition);
|
||||
if (oldPosition < newPosition) {
|
||||
for (int i = oldPosition; i < newPosition; i++) {
|
||||
Collections.swap(datas, i, i + 1);
|
||||
}
|
||||
} else if (oldPosition > newPosition) {
|
||||
for (int i = oldPosition; i > newPosition; i--) {
|
||||
Collections.swap(datas, i, i - 1);
|
||||
}
|
||||
}
|
||||
datas.set(newPosition, temp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHideItem(int hidePosition) {
|
||||
this.currentHidePosition = hidePosition;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
|
@ -1,216 +0,0 @@
|
|||
package com.example.administrator.myapplication.app;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.animation.BounceInterpolator;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
import com.example.administrator.myapplication.db.NoteDatabase;
|
||||
import com.example.administrator.myapplication.entity.NotebookData;
|
||||
import com.example.administrator.myapplication.entity.OnResponseListener;
|
||||
import com.example.administrator.myapplication.entity.Response;
|
||||
import com.example.administrator.myapplication.ui.MainActivity;
|
||||
import com.example.administrator.myapplication.utils.AccountUtils;
|
||||
import com.example.administrator.myapplication.utils.BmobConstants;
|
||||
import com.example.administrator.myapplication.utils.Constants;
|
||||
import com.example.administrator.myapplication.utils.SPUtils;
|
||||
import com.example.administrator.myapplication.utils.StringUtils;
|
||||
import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache;
|
||||
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
|
||||
import com.nostra13.universalimageloader.cache.memory.impl.WeakMemoryCache;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
|
||||
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;
|
||||
import com.nostra13.universalimageloader.utils.StorageUtils;
|
||||
import com.yhao.floatwindow.FloatWindow;
|
||||
import com.yhao.floatwindow.MoveType;
|
||||
import com.yhao.floatwindow.PermissionListener;
|
||||
import com.yhao.floatwindow.Screen;
|
||||
import com.yhao.floatwindow.ViewStateListener;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import cn.bmob.v3.Bmob;
|
||||
|
||||
|
||||
public class BaseApplication extends Application {
|
||||
private NoteDatabase noteDb;
|
||||
private NotebookData editData;
|
||||
private static final String TAG = "FloatWindow";
|
||||
private String ApplicationId="82cacaa4470ab6b8d61d3f0ce6d6201d";
|
||||
private int mFontSizeId;
|
||||
protected boolean isNewNote;
|
||||
static public String avatarPath= BmobConstants.MyAvatarDir+"avatarIcon.png";
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
ImageView imageView = new ImageView(getApplicationContext());
|
||||
imageView.setImageResource(R.drawable.icon);
|
||||
|
||||
FloatWindow
|
||||
.with(getApplicationContext())
|
||||
.setView(imageView)
|
||||
.setWidth(Screen.width, 0.2f) //设置悬浮控件宽高
|
||||
.setHeight(Screen.width, 0.2f)
|
||||
.setX(Screen.width, 0.8f)
|
||||
.setY(Screen.height, 0.3f)
|
||||
.setMoveType(MoveType.slide,100,-100)
|
||||
.setMoveStyle(500, new BounceInterpolator())
|
||||
.setFilter(true, MainActivity.class)
|
||||
.setViewStateListener(mViewStateListener)
|
||||
.setPermissionListener(mPermissionListener)
|
||||
.setDesktopShow(true)
|
||||
.build();
|
||||
|
||||
|
||||
|
||||
//设置点击事件实现一键收藏
|
||||
imageView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Toast.makeText(BaseApplication.this, "嗖藏成功~", Toast.LENGTH_SHORT).show();
|
||||
//获取剪切板内容
|
||||
|
||||
ClipboardManager cbm=(ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clipData = cbm.getPrimaryClip(); //获取当前剪贴板内容
|
||||
ClipData.Item item = clipData.getItemAt(0);
|
||||
String text = item.getText().toString();
|
||||
System.out.println(text);
|
||||
//将剪切板内容转化为notebookdate
|
||||
editData = new NotebookData();
|
||||
if (editData.getId() == 0) {
|
||||
editData.setId(-1
|
||||
* StringUtils.toInt(
|
||||
StringUtils.getDataTime("dddHHmmss"), 0));
|
||||
}
|
||||
String userId = AccountUtils.getUserId(getApplicationContext());
|
||||
editData.setUserId(userId);
|
||||
editData.setObjectId(editData.getObjectId());
|
||||
editData.setUnixTime(StringUtils.getDataTime("yyyy-MM-dd HH:mm:ss"));
|
||||
editData.setIid(editData.getIid()+1);
|
||||
editData.setContent(text);
|
||||
editData.setDate(editData.getDate());
|
||||
//editData.setUserId("23ee9374c5");
|
||||
//editData.setColor(3);//默认为blue
|
||||
//editData.setColorText("blue");
|
||||
isNewNote = true;
|
||||
if (StringUtils.isEmpty(editData.getDate())) {
|
||||
editData.setDate(StringUtils.getDataTime("yyyy/MM/dd"));
|
||||
}
|
||||
|
||||
mFontSizeId= (int) SPUtils.get(getApplicationContext(),Constants.TEXT_SIZE, Constants.TEXT_MEDIUM);
|
||||
//System.out.println(editData.getContent());
|
||||
|
||||
editData.postNoteToServer(getApplicationContext(), new OnResponseListener() {
|
||||
@Override
|
||||
public void onResponse(Response response) {
|
||||
if (!response.isSucces()) {
|
||||
//Snackbar.make(mImgGreen, "保存至服务器端失败,暂保存在本地", Snackbar.LENGTH_LONG).show();
|
||||
Toast.makeText(getApplicationContext(),"保存至服务器端失败,暂保存在本地",Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/* public void initData() {
|
||||
noteDb = new NoteDatabase(null);
|
||||
if (editData == null) {
|
||||
editData = new NotebookData();
|
||||
editData.setContent(text);
|
||||
isNewNote = true;
|
||||
}
|
||||
if (StringUtils.isEmpty(editData.getDate())) {
|
||||
editData.setDate(StringUtils.getDataTime("yyyy/MM/dd"));
|
||||
}
|
||||
|
||||
mFontSizeId= (int) SPUtils.get(getActivity(),Constants.TEXT_SIZE, Constants.TEXT_MEDIUM);
|
||||
}*/
|
||||
|
||||
//悬浮窗口部分
|
||||
initImageLoader(this);
|
||||
Bmob.initialize(this, ApplicationId);
|
||||
// android 7.0系统解决拍照的问题
|
||||
}
|
||||
|
||||
/** 初始化ImageLoader */
|
||||
public static void initImageLoader(Context context) {
|
||||
File cacheDir = StorageUtils.getOwnCacheDirectory(context,
|
||||
"beautynote/cache");// 获取到缓存的目录地址
|
||||
// 创建配置ImageLoader(所有的选项都是可选的,只使用那些你真的想定制),这个可以设定在APPLACATION里面,设置为全局的配置参数
|
||||
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
|
||||
context)
|
||||
|
||||
// 线程池内加载的数量
|
||||
.threadPoolSize(3).threadPriority(Thread.NORM_PRIORITY - 2)
|
||||
.memoryCache(new WeakMemoryCache())
|
||||
.denyCacheImageMultipleSizesInMemory()
|
||||
.discCacheFileNameGenerator(new Md5FileNameGenerator())
|
||||
// 将保存的时候的URI名称用MD5 加密
|
||||
.tasksProcessingOrder(QueueProcessingType.LIFO)
|
||||
.discCache(new UnlimitedDiscCache(cacheDir))// 自定义缓存路径
|
||||
// .defaultDisplayImageOptions(DisplayImageOptions.createSimple())
|
||||
.writeDebugLogs() // Remove for release app
|
||||
.build();
|
||||
// Initialize ImageLoader with configuration.
|
||||
ImageLoader.getInstance().init(config);// 全局初始化此配置
|
||||
}
|
||||
|
||||
/** 悬浮窗日志 */
|
||||
private PermissionListener mPermissionListener = new PermissionListener() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
Log.d(TAG, "onSuccess");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail() {
|
||||
Log.d(TAG, "onFail");
|
||||
}
|
||||
};
|
||||
|
||||
private ViewStateListener mViewStateListener = new ViewStateListener() {
|
||||
@Override
|
||||
public void onPositionUpdate(int x, int y) {
|
||||
Log.d(TAG, "onPositionUpdate: x=" + x + " y=" + y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShow() {
|
||||
Log.d(TAG, "onShow");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHide() {
|
||||
Log.d(TAG, "onHide");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismiss() {
|
||||
Log.d(TAG, "onDismiss");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMoveAnimStart() {
|
||||
Log.d(TAG, "onMoveAnimStart");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMoveAnimEnd() {
|
||||
Log.d(TAG, "onMoveAnimEnd");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackToDesktop() {
|
||||
Log.d(TAG, "onBackToDesktop");
|
||||
}
|
||||
};
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
package com.example.administrator.myapplication.db;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
|
||||
public class DatabaseHelper extends SQLiteOpenHelper {
|
||||
|
||||
public static final String COOLNOTE_DATABASE_NAME = "soucang";
|
||||
|
||||
public static final String NOTE_TABLE_NAME = "sc_Notebook";
|
||||
|
||||
public static final String CREATE_NOTE_TABLE = "create table "
|
||||
+ NOTE_TABLE_NAME
|
||||
+ " (_id integer primary key autoincrement, objectid text, iid integer,"
|
||||
+ " time varchar(10), date varchar(10), content text, color integer)";
|
||||
|
||||
public static final String NEWS_LIST = "osc_news_list";
|
||||
|
||||
public static final String CREATE_NEWS_LIST_TABLE = "create table "
|
||||
+ NOTE_TABLE_NAME + "(" + "_id integer primary key autoincrement, "
|
||||
+ "news_id interger, title varchar(10), " + ")";
|
||||
|
||||
public DatabaseHelper(Context context) {
|
||||
super(context, COOLNOTE_DATABASE_NAME, null, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
db.execSQL(CREATE_NOTE_TABLE);
|
||||
// db.execSQL(CREATE_NEWS_LIST_TABLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {}
|
||||
|
||||
}
|
|
@ -1,180 +0,0 @@
|
|||
package com.example.administrator.myapplication.db;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
|
||||
|
||||
import com.example.administrator.myapplication.entity.NotebookData;
|
||||
import com.example.administrator.myapplication.utils.AccountUtils;
|
||||
import com.example.administrator.myapplication.utils.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class NoteDatabase {
|
||||
private final DatabaseHelper dbHelper;
|
||||
|
||||
public NoteDatabase(Context context) {
|
||||
super();
|
||||
dbHelper = new DatabaseHelper(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* 增
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
public void insert(NotebookData data) {
|
||||
String sql = "insert into " + DatabaseHelper.NOTE_TABLE_NAME;
|
||||
|
||||
sql += "(_id, objectid, iid, time, date, content, color) values(?, ?, ?, ?, ?, ?, ?)";
|
||||
|
||||
SQLiteDatabase sqlite = dbHelper.getWritableDatabase();
|
||||
sqlite.execSQL(sql, new String[] { data.getId() + "",
|
||||
data.getIid() + "", data.getObjectId(), data.getUnixTime() + "", data.getDate(),
|
||||
data.getContent(), data.getColor() + "" });
|
||||
sqlite.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
public void delete(int id) {
|
||||
SQLiteDatabase sqlite = dbHelper.getWritableDatabase();
|
||||
String sql = ("delete from " + DatabaseHelper.NOTE_TABLE_NAME + " where _id=?");
|
||||
sqlite.execSQL(sql, new Integer[] { id });
|
||||
sqlite.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* 改
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
public void update(NotebookData data) {
|
||||
SQLiteDatabase sqlite = dbHelper.getWritableDatabase();
|
||||
String sql = ("update " + DatabaseHelper.NOTE_TABLE_NAME + " set iid=?, objectid=?, time=?, date=?, content=?, color=? where _id=?");
|
||||
sqlite.execSQL(sql,
|
||||
new String[] { data.getIid() + "", data.getObjectId() + "", data.getUnixTime() + "",
|
||||
data.getDate(), data.getContent(),
|
||||
data.getColor() + "", data.getId() + "" });
|
||||
sqlite.close();
|
||||
}
|
||||
|
||||
public List<NotebookData> query() {
|
||||
return query(" ");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查
|
||||
*
|
||||
* @param where
|
||||
* @return
|
||||
*/
|
||||
public List<NotebookData> query(String where) {
|
||||
SQLiteDatabase sqlite = dbHelper.getReadableDatabase();
|
||||
ArrayList<NotebookData> data = null;
|
||||
data = new ArrayList<NotebookData>();
|
||||
Cursor cursor = sqlite.rawQuery("select * from "
|
||||
+ DatabaseHelper.NOTE_TABLE_NAME + where, null);
|
||||
for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
|
||||
NotebookData notebookData = new NotebookData();
|
||||
notebookData.setId(cursor.getInt(0));
|
||||
notebookData.setObjectId(cursor.getString(1));
|
||||
notebookData.setIid(cursor.getInt(2));
|
||||
notebookData.setUnixTime(cursor.getString(3));
|
||||
notebookData.setDate(cursor.getString(4));
|
||||
notebookData.setContent(cursor.getString(5));
|
||||
notebookData.setColor(cursor.getInt(6));
|
||||
data.add(notebookData);
|
||||
}
|
||||
if (!cursor.isClosed()) {
|
||||
cursor.close();
|
||||
}
|
||||
sqlite.close();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置
|
||||
*
|
||||
* @param datas
|
||||
*/
|
||||
public void reset(List<NotebookData> datas) {
|
||||
if (datas != null) {
|
||||
SQLiteDatabase sqlite = dbHelper.getWritableDatabase();
|
||||
// 删除全部
|
||||
sqlite.execSQL("delete from " + DatabaseHelper.NOTE_TABLE_NAME);
|
||||
// 重新添加
|
||||
for (NotebookData data : datas) {
|
||||
insert(data);
|
||||
}
|
||||
sqlite.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存一条数据到本地(若已存在则直接覆盖)
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
public void save(NotebookData data) {
|
||||
List<NotebookData> datas = query(" where _id=" + data.getId());
|
||||
if (datas != null && !datas.isEmpty()) {
|
||||
update(data);
|
||||
} else {
|
||||
insert(data);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// /**
|
||||
// * 合并一条数据到本地(通过更新时间判断仅保留最新)
|
||||
// *
|
||||
// * @param data
|
||||
// * @return 数据是否被合并了
|
||||
// */
|
||||
// public boolean merge(NotebookData data) {
|
||||
// Cursor cursor = sqlite.rawQuery(
|
||||
// "select * from " + DatabaseHelper.NOTE_TABLE_NAME
|
||||
// + " where _id=" + data.getId(), null);
|
||||
// NotebookData localData = new NotebookData();
|
||||
// // 本循环其实只执行一次
|
||||
// for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
|
||||
// localData.setId(cursor.getInt(0));
|
||||
// localData.setIid(cursor.getInt(1));
|
||||
// localData.setUnixTime(cursor.getString(2));
|
||||
// localData.setDate(cursor.getString(3));
|
||||
// localData.setContent(cursor.getString(4));
|
||||
// localData.setColor(cursor.getInt(5));
|
||||
// }
|
||||
// // 是否需要合这条数据
|
||||
// boolean isMerge = localData.getUnixTime() < data.getUnixTime();
|
||||
// if (isMerge) {
|
||||
// save(data);
|
||||
// }
|
||||
// return isMerge;
|
||||
// }
|
||||
|
||||
public void destroy() {
|
||||
dbHelper.close();
|
||||
}
|
||||
|
||||
public void insertIntroduce(Context context)
|
||||
{
|
||||
NotebookData editData=new NotebookData();
|
||||
if (editData.getId() == 0) {
|
||||
editData.setId(-1
|
||||
* StringUtils.toInt(
|
||||
StringUtils.getDataTime("dddHHmmss"), 0));
|
||||
}
|
||||
editData.setUnixTime(StringUtils.getDataTime("yyyy-MM-dd HH:mm:ss"));
|
||||
editData.setContent("欢迎使用嗖藏,赶快记下你此刻的灵感吧!");
|
||||
editData.setUserId(AccountUtils.getUserId(context));
|
||||
save(editData);
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
package com.example.administrator.myapplication.entity;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
public class BgPicEntity {
|
||||
public Bitmap bitmap;
|
||||
public String path;
|
||||
}
|
|
@ -1,245 +0,0 @@
|
|||
package com.example.administrator.myapplication.entity;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import cn.bmob.v3.BmobObject;
|
||||
import cn.bmob.v3.listener.DeleteListener;
|
||||
import cn.bmob.v3.listener.SaveListener;
|
||||
import cn.bmob.v3.listener.UpdateListener;
|
||||
|
||||
|
||||
public class NotebookData extends BmobObject implements /*Serializable,*/
|
||||
Comparable<NotebookData> {
|
||||
|
||||
|
||||
private int id;
|
||||
private int iid;
|
||||
|
||||
private String userId;//用于服务器端存储需要
|
||||
|
||||
private String unixTime;
|
||||
|
||||
private String date;
|
||||
|
||||
private String content;
|
||||
|
||||
private String colorText;
|
||||
|
||||
private int color;
|
||||
public static final String NOTE_USER_ID = "userId";
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (super.equals(o)) {
|
||||
return true;
|
||||
} else {
|
||||
if (o instanceof NotebookData) {
|
||||
NotebookData data = (NotebookData) o;
|
||||
try {
|
||||
return (this.id == data.getId())
|
||||
&& (this.iid == data.getIid())
|
||||
&& (this.unixTime == data.getUnixTime())
|
||||
&& (this.date.equals(data.getDate()))
|
||||
&& (this.content == data.getContent())
|
||||
&& (this.color == data.getColor());
|
||||
} catch (NullPointerException e) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void postNoteToServer(Context context,final com.example.administrator.myapplication.entity.OnResponseListener listener)
|
||||
{
|
||||
// for(int i=0;i<data.size();i++) {
|
||||
save(context, new SaveListener() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
if (listener != null) {
|
||||
com.example.administrator.myapplication.entity.Response response = new Response();
|
||||
response.setIsSucces(true);
|
||||
listener.onResponse(response);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(int code, String msg) {
|
||||
if (listener != null) {
|
||||
com.example.administrator.myapplication.entity.Response response = new Response();
|
||||
response.setIsSucces(false);
|
||||
response.setMsg(msg);
|
||||
listener.onResponse(response);
|
||||
}
|
||||
}
|
||||
});
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param context
|
||||
* @param listener
|
||||
*/
|
||||
public void updateNoteInServe(Context context,String objectId,final com.example.administrator.myapplication.entity.OnResponseListener listener)
|
||||
{
|
||||
//objectId,
|
||||
update(context, new UpdateListener() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
if (listener != null) {
|
||||
com.example.administrator.myapplication.entity.Response response = new Response();
|
||||
response.setIsSucces(true);
|
||||
listener.onResponse(response);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(int code, String msg) {
|
||||
if (listener != null) {
|
||||
com.example.administrator.myapplication.entity.Response response = new Response();
|
||||
response.setIsSucces(false);
|
||||
response.setMsg(msg);
|
||||
listener.onResponse(response);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
public void deleteNoteInServe(Context context,/*int noteId,*/final com.example.administrator.myapplication.entity.OnResponseListener listener)
|
||||
{
|
||||
// String objectId=new NoteDatabase().query();
|
||||
|
||||
delete(context, new DeleteListener() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
if (listener != null) {
|
||||
com.example.administrator.myapplication.entity.Response response = new Response();
|
||||
response.setIsSucces(true);
|
||||
listener.onResponse(response);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(int code, String msg) {
|
||||
if (listener != null) {
|
||||
com.example.administrator.myapplication.entity.Response response = new Response();
|
||||
response.setIsSucces(false);
|
||||
response.setMsg(msg);
|
||||
listener.onResponse(response);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getIid() {
|
||||
return iid;
|
||||
}
|
||||
|
||||
public void setIid(int iid) {
|
||||
this.iid = iid;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(String date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public String getUnixTime() {
|
||||
return unixTime;
|
||||
}
|
||||
|
||||
public void setUnixTime(String time) {
|
||||
this.unixTime = time;
|
||||
// setServerUpdateTime(time);
|
||||
}
|
||||
|
||||
public String getColorText() {
|
||||
return colorText;
|
||||
}
|
||||
|
||||
public void setColorText(String color) {
|
||||
this.colorText = color;
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
// 客户端始终以当前手机上的颜色为准
|
||||
if ("blue".equals(colorText)) {
|
||||
this.color = 3;
|
||||
} else if ("red".equals(colorText)) {
|
||||
this.color = 2;
|
||||
} else if ("yellow".equals(colorText)) {
|
||||
this.color = 1;
|
||||
} else if ("purple".equals(colorText)) {
|
||||
this.color = 4;
|
||||
} else if ("green".equals(colorText)) {
|
||||
this.color = 0;
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
// public String getServerUpdateTime() {
|
||||
// return serverUpdateTime;
|
||||
// }
|
||||
//
|
||||
// public void setServerUpdateTime(String serverUpdateTime) {
|
||||
// this.serverUpdateTime = serverUpdateTime;
|
||||
// }
|
||||
|
||||
public void setColor(int color) {
|
||||
switch (color) {
|
||||
case 0:
|
||||
colorText = "green";
|
||||
break;
|
||||
case 1:
|
||||
colorText = "yellow";
|
||||
break;
|
||||
case 2:
|
||||
colorText = "red";
|
||||
break;
|
||||
case 3:
|
||||
colorText = "blue";
|
||||
break;
|
||||
case 4:
|
||||
colorText = "purple";
|
||||
break;
|
||||
default:
|
||||
this.color = color;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(NotebookData another) {
|
||||
return this.iid - another.getIid();
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package com.example.administrator.myapplication.entity;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 服务器回复的回调接口
|
||||
*
|
||||
*/
|
||||
public interface OnResponseListener {
|
||||
|
||||
/**
|
||||
* 成功
|
||||
* @param response 回复的结果
|
||||
*/
|
||||
void onResponse(com.example.administrator.myapplication.entity.Response response);
|
||||
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
package com.example.administrator.myapplication.entity;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 服务器响应类
|
||||
*
|
||||
*/
|
||||
public class Response {
|
||||
|
||||
private String msg;
|
||||
private boolean isSucces;
|
||||
|
||||
private List<NotebookData> noteItemList;
|
||||
// private List<DiaryItem> diaryItemList;
|
||||
private Bitmap bitmap;
|
||||
|
||||
public Bitmap getBitmap() {
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
public void setBitmap(Bitmap bitmap) {
|
||||
this.bitmap = bitmap;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public boolean isSucces() {
|
||||
return isSucces;
|
||||
}
|
||||
|
||||
public void setIsSucces(boolean isSucces) {
|
||||
this.isSucces = isSucces;
|
||||
}
|
||||
|
||||
public List<NotebookData> getNoteItemList() {
|
||||
return noteItemList;
|
||||
}
|
||||
|
||||
public void setNoteItemList(List<NotebookData> noteItemList) {
|
||||
this.noteItemList = noteItemList;
|
||||
}
|
||||
|
||||
// public List<DiaryItem> getDiaryItemList() {
|
||||
// return diaryItemList;
|
||||
// }
|
||||
//
|
||||
// public void setDiaryItemList(List<DiaryItem> diaryItemList) {
|
||||
// this.diaryItemList = diaryItemList;
|
||||
// }
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package com.example.administrator.myapplication.entity;
|
||||
|
||||
/**
|
||||
* 配合EvetnBus使用
|
||||
*/
|
||||
public class UpdataEvent {
|
||||
public static final int UPDATE_NOTES = 0;
|
||||
public static final int UPDATE_DIARIES = 1;
|
||||
public static final int UPDATE_USER_INFOS = 2;
|
||||
private int type;
|
||||
private String content;
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
public void setString(String str)
|
||||
{
|
||||
this.content=str;
|
||||
}
|
||||
public String getString()
|
||||
{
|
||||
return content;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,298 +0,0 @@
|
|||
package com.example.administrator.myapplication.entity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
import com.example.administrator.myapplication.app.BaseApplication;
|
||||
import com.example.administrator.myapplication.utils.AccountUtils;
|
||||
import com.example.administrator.myapplication.utils.BmobConstants;
|
||||
import com.example.administrator.myapplication.utils.ImageLoadOptions;
|
||||
import com.example.administrator.myapplication.utils.SPUtils;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cn.bmob.v3.Bmob;
|
||||
import cn.bmob.v3.BmobQuery;
|
||||
import cn.bmob.v3.BmobUser;
|
||||
import cn.bmob.v3.datatype.BmobFile;
|
||||
import cn.bmob.v3.exception.BmobException;
|
||||
import cn.bmob.v3.listener.DeleteListener;
|
||||
import cn.bmob.v3.listener.FindListener;
|
||||
import cn.bmob.v3.listener.LogInListener;
|
||||
import cn.bmob.v3.listener.SaveListener;
|
||||
import cn.bmob.v3.listener.UpdateListener;
|
||||
|
||||
|
||||
public class User extends BmobUser implements Serializable{
|
||||
|
||||
private String nickname;
|
||||
private String sex;
|
||||
private String notePwd;
|
||||
private String headUrl;
|
||||
|
||||
public String getUserNickname() {
|
||||
if (!TextUtils.isEmpty(nickname))
|
||||
return nickname;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
public void setUserNickname(String nickname) {
|
||||
this.nickname = nickname;
|
||||
}
|
||||
|
||||
public String getUserSex() {
|
||||
if (!TextUtils.isEmpty(sex))
|
||||
return sex;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
public void setUserSex(String sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public String getUserNotePwd() {
|
||||
if (!TextUtils.isEmpty(notePwd))
|
||||
return notePwd;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
public void setUserNotePwd(String notePwd) {
|
||||
this.notePwd = notePwd;
|
||||
}
|
||||
|
||||
public String getUserHeadUrl() {
|
||||
if (!TextUtils.isEmpty(headUrl))
|
||||
return headUrl;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
public void setUserHeadUrl(String headUrl) {
|
||||
this.headUrl = headUrl;
|
||||
}
|
||||
|
||||
public void Login(String account ,String pwd ,final Context context)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
static public void setUserHeadFromCache(Context context, ImageView img){
|
||||
String mSavePath=context.getCacheDir().getAbsolutePath();
|
||||
File saveFile = new File(mSavePath, "userHead");
|
||||
Bitmap bitmap = BitmapFactory.decodeFile(saveFile.getAbsolutePath());
|
||||
img.setImageBitmap(bitmap);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新头像 refreshAvatar
|
||||
*
|
||||
* @return void
|
||||
* @throws
|
||||
*/
|
||||
static public void refreshAvatarFromServe(String avatar,ImageView headIcon) {
|
||||
if (avatar != null && !avatar.equals("")) {
|
||||
ImageLoader.getInstance().displayImage(avatar,headIcon,
|
||||
ImageLoadOptions.getOptions());
|
||||
} else {
|
||||
headIcon.setImageResource(R.mipmap.mine_avatar);
|
||||
}
|
||||
|
||||
}
|
||||
static public void refreshAvatarFromLoca(Context context,ImageView headIcon) {
|
||||
// if (avatar != null && !avatar.equals("")) {
|
||||
//imageLoader.init();
|
||||
File saveFile = new File(BmobConstants.MyAvatarDir, "avatarIcon.png");
|
||||
if(saveFile.exists())//先从本地获取
|
||||
{
|
||||
Bitmap bitmap = BitmapFactory.decodeFile(saveFile.getAbsolutePath());
|
||||
headIcon.setImageBitmap(bitmap);
|
||||
}else//从网络上获取,如果失败显示默认图片
|
||||
{
|
||||
initDefaultAvatar(context, headIcon);
|
||||
}
|
||||
// Bitmap bitmap = BitmapFactory.decodeFile(saveFile.getAbsolutePath());
|
||||
// headIcon.setImageBitmap(bitmap);
|
||||
// ImageLoader.getInstance().displayImage(/*"file://"+*/avatar,headIcon,
|
||||
// ImageLoadOptions.getOptions());
|
||||
// } else {
|
||||
// headIcon.setImageResource(R.drawable.default_head);
|
||||
// }
|
||||
}
|
||||
|
||||
static public void initDefaultAvatar(Context context,ImageView headIcon)
|
||||
{
|
||||
// String defaultPath= BmobConstants.MyAvatarDir+"avatarIcon.png";
|
||||
if(!setUserHeadFromServer(context, headIcon))
|
||||
{
|
||||
headIcon.setImageResource(R.drawable.default_head);
|
||||
}
|
||||
// boolean isSetAvatar= (boolean) SPUtils.get(context,"isSetAvatar",false);
|
||||
// if(!isSetAvatar)
|
||||
//
|
||||
// else
|
||||
// {
|
||||
// Log.i("head","get user icon form srver");
|
||||
// setUserHeadFromServer(context, headIcon);
|
||||
//// ImageLoader.getInstance().displayImage("file://"+defaultPath,headIcon,
|
||||
//// ImageLoadOptions.getOptions());
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
static public void autoLogin(Context context, final OnResponseListener listener)
|
||||
{
|
||||
if(SPUtils.contains(context,"user_name"))
|
||||
{
|
||||
String name=(String)SPUtils.get(context,"user_name","");
|
||||
String pwd=(String)SPUtils.get(context,"pwd","");
|
||||
BmobUser user = new BmobUser();
|
||||
user.setUsername(name);
|
||||
user.setPassword(pwd);
|
||||
user.login(context, new SaveListener() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
if(listener!=null)
|
||||
{
|
||||
Response response = new Response();
|
||||
response.setIsSucces(true);
|
||||
listener.onResponse(response);
|
||||
}
|
||||
// Snackbar.make(loginBtn,"登录成功!",Snackbar.LENGTH_SHORT).show();
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onFailure(int code, String msg) {
|
||||
if(listener!=null)
|
||||
{
|
||||
Response response = new Response();
|
||||
response.setIsSucces(false);
|
||||
response.setMsg(msg);
|
||||
listener.onResponse(response);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static public void getUserNotes(Context context, String user_id,final OnResponseListener listener){
|
||||
// Bmob.initialize(context, Constants.APPLICATION_ID);
|
||||
final List<NotebookData> list = new ArrayList<NotebookData>();
|
||||
BmobQuery<NotebookData> query = new BmobQuery<NotebookData>();
|
||||
|
||||
query.addWhereEqualTo(NotebookData.NOTE_USER_ID, user_id);
|
||||
//返回50条数据,如果不加上这条语句,默认返回10条数据
|
||||
query.setLimit(50);
|
||||
//按更新日期降序排列
|
||||
query.order("-updatedAt");
|
||||
//执行查询方法
|
||||
query.findObjects(context, new FindListener<NotebookData>() {
|
||||
@Override
|
||||
public void onSuccess(List<NotebookData> object) {
|
||||
if (listener != null) {
|
||||
Response response = new Response();
|
||||
response.setIsSucces(true);
|
||||
response.setNoteItemList(object);
|
||||
listener.onResponse(response);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
Response response = new Response();
|
||||
response.setIsSucces(false);
|
||||
response.setMsg(msg);
|
||||
listener.onResponse(response);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 更新用户表单中的头像列
|
||||
*
|
||||
* @param picUrl 图片的url
|
||||
*/
|
||||
private void updateUserHead(Context context, String picUrl, final OnResponseListener listener) {
|
||||
String oldUrl = AccountUtils.getUserHeadUrl(context);
|
||||
if (!TextUtils.isEmpty(oldUrl) && !oldUrl.equals("")) {
|
||||
//删除服务器上的旧头像
|
||||
deleteUserOldHead(context, oldUrl);
|
||||
}
|
||||
AccountUtils.saveUserHeadUrl(context, picUrl);
|
||||
User user = new User();
|
||||
user.setUserHeadUrl(picUrl);
|
||||
user.update(context, AccountUtils.getUserId(context), new UpdateListener() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
if (listener != null) {
|
||||
Response response = new Response();
|
||||
response.setIsSucces(true);
|
||||
listener.onResponse(response);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(int code, String msg) {
|
||||
if (listener != null) {
|
||||
Response response = new Response();
|
||||
response.setIsSucces(false);
|
||||
response.setMsg(msg);
|
||||
listener.onResponse(response);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除服务器上的旧头像
|
||||
*
|
||||
* @param oldUrl 旧头像的url
|
||||
*/
|
||||
private void deleteUserOldHead(Context context, String oldUrl) {
|
||||
BmobFile file = new BmobFile();
|
||||
file.setUrl(oldUrl);//此url是上传文件成功之后通过bmobFile.getUrl()方法获取的。
|
||||
file.delete(context, new DeleteListener() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(int code, String msg) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
static public boolean setUserHeadFromServer(Context context, ImageView headIcon) {
|
||||
|
||||
String photoUrl = AccountUtils.getUserHeadUrl(context).trim();
|
||||
|
||||
// Toast.makeText(context,photoUrl,Toast.LENGTH_LONG).show();
|
||||
if (!TextUtils.isEmpty(photoUrl) && !photoUrl.equals("")) {
|
||||
ImageLoader.getInstance().displayImage(photoUrl,headIcon,
|
||||
ImageLoadOptions.getOptions());
|
||||
return true;
|
||||
}
|
||||
return false;//说明用户第一次使用该App或者未修改head
|
||||
}
|
||||
|
||||
// static public String getUserHeadPath()
|
||||
// {
|
||||
// String path=null;
|
||||
// return path;
|
||||
// }
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.text.util.Linkify;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
|
||||
|
||||
public class AboutAppFragment extends Fragment {
|
||||
private View baseView;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
baseView=inflater.inflate(R.layout.about_me_fragment, null);
|
||||
initView();
|
||||
return baseView;
|
||||
|
||||
}
|
||||
private void initView()
|
||||
{
|
||||
TextView aboutMeTv=(TextView) baseView.findViewById(R.id.about_me_tv);
|
||||
Linkify.addLinks(aboutMeTv, Linkify.ALL);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,157 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.content.DialogInterface.OnDismissListener;
|
||||
import android.content.Intent;
|
||||
import android.media.AudioManager;
|
||||
import android.media.MediaPlayer;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.provider.Settings;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
import com.example.administrator.myapplication.utils.Constants;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
public class AlarmAlertActivity extends Activity implements OnClickListener, OnDismissListener {
|
||||
private long mNoteId;
|
||||
private String mSnippet;
|
||||
private static final int SNIPPET_PREW_MAX_LEN = 60;
|
||||
MediaPlayer mPlayer;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
|
||||
final Window win = getWindow();
|
||||
win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
|
||||
|
||||
if (!isScreenOn()) {
|
||||
win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
|
||||
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
|
||||
| WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
|
||||
| WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR);
|
||||
}
|
||||
|
||||
Intent intent = getIntent();
|
||||
|
||||
try {
|
||||
// mNoteId = Long.valueOf(intent.getData().getPathSegments().get(1));
|
||||
mSnippet = intent.getStringExtra(Constants.ALART_CONTENT);//DataUtils.getSnippetById(this.getContentResolver(), mNoteId);
|
||||
mSnippet = mSnippet.length() > SNIPPET_PREW_MAX_LEN ?( mSnippet.substring(0,
|
||||
SNIPPET_PREW_MAX_LEN) + "...")
|
||||
: mSnippet;
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
mPlayer = new MediaPlayer();
|
||||
// if (DataUtils.visibleInNoteDatabase(getContentResolver(), mNoteId, Notes.TYPE_NOTE)) {
|
||||
showActionDialog();
|
||||
playAlarmSound();
|
||||
// } else {
|
||||
// finish();
|
||||
// }
|
||||
}
|
||||
|
||||
private boolean isScreenOn() {
|
||||
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||
return pm.isScreenOn();
|
||||
}
|
||||
|
||||
private void playAlarmSound() {
|
||||
Uri url = RingtoneManager.getActualDefaultRingtoneUri(this, RingtoneManager.TYPE_ALARM);
|
||||
|
||||
int silentModeStreams = Settings.System.getInt(getContentResolver(),
|
||||
Settings.System.MODE_RINGER_STREAMS_AFFECTED, 0);
|
||||
|
||||
if ((silentModeStreams & (1 << AudioManager.STREAM_ALARM)) != 0) {
|
||||
mPlayer.setAudioStreamType(silentModeStreams);
|
||||
} else {
|
||||
mPlayer.setAudioStreamType(AudioManager.STREAM_ALARM);
|
||||
}
|
||||
try {
|
||||
mPlayer.setDataSource(this, url);
|
||||
mPlayer.prepare();
|
||||
mPlayer.setLooping(true);
|
||||
mPlayer.start();
|
||||
} catch (IllegalArgumentException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (SecurityException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IllegalStateException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void showActionDialog() {
|
||||
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
|
||||
dialog.setTitle(R.string.app_name);
|
||||
dialog.setMessage(mSnippet);
|
||||
dialog.setPositiveButton(R.string.notealert_cancle, this);
|
||||
if (isScreenOn()) {
|
||||
dialog.setNegativeButton(R.string.notealert_look, this);
|
||||
}
|
||||
dialog.show().setOnDismissListener(this);
|
||||
}
|
||||
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
switch (which) {
|
||||
case DialogInterface.BUTTON_NEGATIVE:
|
||||
Intent intent = new Intent(this, NoteEditActivity.class);
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
intent.putExtra(Intent.EXTRA_UID, mNoteId);
|
||||
startActivity(intent);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
stopAlarmSound();
|
||||
finish();
|
||||
}
|
||||
|
||||
private void stopAlarmSound() {
|
||||
if (mPlayer != null) {
|
||||
mPlayer.stop();
|
||||
mPlayer.release();
|
||||
mPlayer = null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,91 +0,0 @@
|
|||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
import android.content.res.AssetManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
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.GridView;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
import com.example.administrator.myapplication.adapter.BgPicGridAdapter;
|
||||
import com.example.administrator.myapplication.entity.BgPicEntity;
|
||||
import com.example.administrator.myapplication.utils.SystemUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by htq on 2016/8/11.
|
||||
*/
|
||||
public class ChangeBgFragment extends Fragment {
|
||||
|
||||
private List<BgPicEntity> mBgPicList;
|
||||
private View baseView;
|
||||
private GridView mGridView;
|
||||
private BgPicGridAdapter mBgPicAdapter;
|
||||
private SystemUtils systemUtils;
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
baseView = inflater.inflate(R.layout.fragment_change_background, null);
|
||||
initBackgroundPic();
|
||||
initView();
|
||||
return baseView;
|
||||
}
|
||||
private void initView()
|
||||
{
|
||||
|
||||
mGridView = (GridView) baseView.findViewById(R.id.change_background_grid);
|
||||
mBgPicAdapter = new BgPicGridAdapter(getActivity(),mBgPicList);
|
||||
mGridView.setOnItemClickListener(gridItemClickListener);
|
||||
mGridView.setAdapter(mBgPicAdapter);
|
||||
|
||||
}
|
||||
private void initBackgroundPic()
|
||||
{
|
||||
AssetManager am = getActivity().getAssets();
|
||||
try {
|
||||
String[] drawableList = am.list("bkgs");
|
||||
mBgPicList = new ArrayList<BgPicEntity>();
|
||||
for (String path : drawableList) {
|
||||
BgPicEntity bg = new BgPicEntity();
|
||||
InputStream is = am.open("bkgs/" + path);
|
||||
Bitmap bitmap = BitmapFactory.decodeStream(is);
|
||||
bg.path = path;
|
||||
bg.bitmap = bitmap;
|
||||
mBgPicList.add(bg);
|
||||
is.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
AdapterView.OnItemClickListener gridItemClickListener=new AdapterView.OnItemClickListener() {
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
// TODO Auto-generated method stub
|
||||
String path = ((BgPicEntity) mBgPicAdapter.getItem(position)).path;
|
||||
|
||||
systemUtils = new SystemUtils(getActivity());
|
||||
systemUtils.saveBgPicPath(path);
|
||||
Bitmap bitmap = systemUtils.getBitmapByPath(getActivity(), path);
|
||||
if (bitmap != null) {
|
||||
((MainActivity) getActivity()).drawer.setBackgroundDrawable(new BitmapDrawable(getResources(), bitmap));
|
||||
mBgPicAdapter.notifyDataSetChanged();
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
|
@ -1,470 +0,0 @@
|
|||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.format.DateFormat;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.NumberPicker;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
|
||||
import java.text.DateFormatSymbols;
|
||||
import java.util.Calendar;
|
||||
|
||||
|
||||
public class DateTimePicker extends FrameLayout {
|
||||
|
||||
private static final boolean DEFAULT_ENABLE_STATE = true;
|
||||
|
||||
private static final int HOURS_IN_HALF_DAY = 12;
|
||||
private static final int HOURS_IN_ALL_DAY = 24;
|
||||
private static final int DAYS_IN_ALL_WEEK = 7;
|
||||
private static final int DATE_SPINNER_MIN_VAL = 0;
|
||||
private static final int DATE_SPINNER_MAX_VAL = DAYS_IN_ALL_WEEK - 1;
|
||||
private static final int HOUR_SPINNER_MIN_VAL_24_HOUR_VIEW = 0;
|
||||
private static final int HOUR_SPINNER_MAX_VAL_24_HOUR_VIEW = 23;
|
||||
private static final int HOUR_SPINNER_MIN_VAL_12_HOUR_VIEW = 1;
|
||||
private static final int HOUR_SPINNER_MAX_VAL_12_HOUR_VIEW = 12;
|
||||
private static final int MINUT_SPINNER_MIN_VAL = 0;
|
||||
private static final int MINUT_SPINNER_MAX_VAL = 59;
|
||||
private static final int AMPM_SPINNER_MIN_VAL = 0;
|
||||
private static final int AMPM_SPINNER_MAX_VAL = 1;
|
||||
|
||||
private final NumberPicker mDateSpinner;
|
||||
private final NumberPicker mHourSpinner;
|
||||
private final NumberPicker mMinuteSpinner;
|
||||
private final NumberPicker mAmPmSpinner;
|
||||
private Calendar mDate;
|
||||
|
||||
private String[] mDateDisplayValues = new String[DAYS_IN_ALL_WEEK];
|
||||
|
||||
private boolean mIsAm;
|
||||
|
||||
private boolean mIs24HourView;
|
||||
|
||||
private boolean mIsEnabled = DEFAULT_ENABLE_STATE;
|
||||
|
||||
private boolean mInitialising;
|
||||
|
||||
private OnDateTimeChangedListener mOnDateTimeChangedListener;
|
||||
|
||||
private NumberPicker.OnValueChangeListener mOnDateChangedListener = new NumberPicker.OnValueChangeListener() {
|
||||
@Override
|
||||
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
|
||||
mDate.add(Calendar.DAY_OF_YEAR, newVal - oldVal);
|
||||
updateDateControl();
|
||||
onDateTimeChanged();
|
||||
}
|
||||
};
|
||||
|
||||
private NumberPicker.OnValueChangeListener mOnHourChangedListener = new NumberPicker.OnValueChangeListener() {
|
||||
@Override
|
||||
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
|
||||
boolean isDateChanged = false;
|
||||
Calendar cal = Calendar.getInstance();
|
||||
if (!mIs24HourView) {
|
||||
if (!mIsAm && oldVal == HOURS_IN_HALF_DAY - 1 && newVal == HOURS_IN_HALF_DAY) {
|
||||
cal.setTimeInMillis(mDate.getTimeInMillis());
|
||||
cal.add(Calendar.DAY_OF_YEAR, 1);
|
||||
isDateChanged = true;
|
||||
} else if (mIsAm && oldVal == HOURS_IN_HALF_DAY && newVal == HOURS_IN_HALF_DAY - 1) {
|
||||
cal.setTimeInMillis(mDate.getTimeInMillis());
|
||||
cal.add(Calendar.DAY_OF_YEAR, -1);
|
||||
isDateChanged = true;
|
||||
}
|
||||
if (oldVal == HOURS_IN_HALF_DAY - 1 && newVal == HOURS_IN_HALF_DAY ||
|
||||
oldVal == HOURS_IN_HALF_DAY && newVal == HOURS_IN_HALF_DAY - 1) {
|
||||
mIsAm = !mIsAm;
|
||||
updateAmPmControl();
|
||||
}
|
||||
} else {
|
||||
if (oldVal == HOURS_IN_ALL_DAY - 1 && newVal == 0) {
|
||||
cal.setTimeInMillis(mDate.getTimeInMillis());
|
||||
cal.add(Calendar.DAY_OF_YEAR, 1);
|
||||
isDateChanged = true;
|
||||
} else if (oldVal == 0 && newVal == HOURS_IN_ALL_DAY - 1) {
|
||||
cal.setTimeInMillis(mDate.getTimeInMillis());
|
||||
cal.add(Calendar.DAY_OF_YEAR, -1);
|
||||
isDateChanged = true;
|
||||
}
|
||||
}
|
||||
int newHour = mHourSpinner.getValue() % HOURS_IN_HALF_DAY + (mIsAm ? 0 : HOURS_IN_HALF_DAY);
|
||||
mDate.set(Calendar.HOUR_OF_DAY, newHour);
|
||||
onDateTimeChanged();
|
||||
if (isDateChanged) {
|
||||
setCurrentYear(cal.get(Calendar.YEAR));
|
||||
setCurrentMonth(cal.get(Calendar.MONTH));
|
||||
setCurrentDay(cal.get(Calendar.DAY_OF_MONTH));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private NumberPicker.OnValueChangeListener mOnMinuteChangedListener = new NumberPicker.OnValueChangeListener() {
|
||||
@Override
|
||||
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
|
||||
int minValue = mMinuteSpinner.getMinValue();
|
||||
int maxValue = mMinuteSpinner.getMaxValue();
|
||||
int offset = 0;
|
||||
if (oldVal == maxValue && newVal == minValue) {
|
||||
offset += 1;
|
||||
} else if (oldVal == minValue && newVal == maxValue) {
|
||||
offset -= 1;
|
||||
}
|
||||
if (offset != 0) {
|
||||
mDate.add(Calendar.HOUR_OF_DAY, offset);
|
||||
mHourSpinner.setValue(getCurrentHour());
|
||||
updateDateControl();
|
||||
int newHour = getCurrentHourOfDay();
|
||||
if (newHour >= HOURS_IN_HALF_DAY) {
|
||||
mIsAm = false;
|
||||
updateAmPmControl();
|
||||
} else {
|
||||
mIsAm = true;
|
||||
updateAmPmControl();
|
||||
}
|
||||
}
|
||||
mDate.set(Calendar.MINUTE, newVal);
|
||||
onDateTimeChanged();
|
||||
}
|
||||
};
|
||||
|
||||
private NumberPicker.OnValueChangeListener mOnAmPmChangedListener = new NumberPicker.OnValueChangeListener() {
|
||||
@Override
|
||||
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
|
||||
mIsAm = !mIsAm;
|
||||
if (mIsAm) {
|
||||
mDate.add(Calendar.HOUR_OF_DAY, -HOURS_IN_HALF_DAY);
|
||||
} else {
|
||||
mDate.add(Calendar.HOUR_OF_DAY, HOURS_IN_HALF_DAY);
|
||||
}
|
||||
updateAmPmControl();
|
||||
onDateTimeChanged();
|
||||
}
|
||||
};
|
||||
|
||||
public interface OnDateTimeChangedListener {
|
||||
void onDateTimeChanged(DateTimePicker view, int year, int month,
|
||||
int dayOfMonth, int hourOfDay, int minute);
|
||||
}
|
||||
|
||||
public DateTimePicker(Context context) {
|
||||
this(context, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public DateTimePicker(Context context, long date) {
|
||||
this(context, date, DateFormat.is24HourFormat(context));
|
||||
}
|
||||
|
||||
public DateTimePicker(Context context, long date, boolean is24HourView) {
|
||||
super(context);
|
||||
mDate = Calendar.getInstance();
|
||||
mInitialising = true;
|
||||
mIsAm = getCurrentHourOfDay() >= HOURS_IN_HALF_DAY;
|
||||
inflate(context, R.layout.datetime_picker, this);
|
||||
|
||||
mDateSpinner = (NumberPicker) findViewById(R.id.date);
|
||||
mDateSpinner.setMinValue(DATE_SPINNER_MIN_VAL);
|
||||
mDateSpinner.setMaxValue(DATE_SPINNER_MAX_VAL);
|
||||
mDateSpinner.setOnValueChangedListener(mOnDateChangedListener);
|
||||
|
||||
mHourSpinner = (NumberPicker) findViewById(R.id.hour);
|
||||
mHourSpinner.setOnValueChangedListener(mOnHourChangedListener);
|
||||
mMinuteSpinner = (NumberPicker) findViewById(R.id.minute);
|
||||
mMinuteSpinner.setMinValue(MINUT_SPINNER_MIN_VAL);
|
||||
mMinuteSpinner.setMaxValue(MINUT_SPINNER_MAX_VAL);
|
||||
mMinuteSpinner.setOnLongPressUpdateInterval(100);
|
||||
mMinuteSpinner.setOnValueChangedListener(mOnMinuteChangedListener);
|
||||
|
||||
String[] stringsForAmPm = new DateFormatSymbols().getAmPmStrings();
|
||||
mAmPmSpinner = (NumberPicker) findViewById(R.id.amPm);
|
||||
mAmPmSpinner.setMinValue(AMPM_SPINNER_MIN_VAL);
|
||||
mAmPmSpinner.setMaxValue(AMPM_SPINNER_MAX_VAL);
|
||||
mAmPmSpinner.setDisplayedValues(stringsForAmPm);
|
||||
mAmPmSpinner.setOnValueChangedListener(mOnAmPmChangedListener);
|
||||
|
||||
// update controls to initial state
|
||||
updateDateControl();
|
||||
updateHourControl();
|
||||
updateAmPmControl();
|
||||
|
||||
set24HourView(is24HourView);
|
||||
|
||||
// set to current time
|
||||
setCurrentDate(date);
|
||||
|
||||
setEnabled(isEnabled());
|
||||
|
||||
// set the content descriptions
|
||||
mInitialising = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
if (mIsEnabled == enabled) {
|
||||
return;
|
||||
}
|
||||
super.setEnabled(enabled);
|
||||
mDateSpinner.setEnabled(enabled);
|
||||
mMinuteSpinner.setEnabled(enabled);
|
||||
mHourSpinner.setEnabled(enabled);
|
||||
mAmPmSpinner.setEnabled(enabled);
|
||||
mIsEnabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return mIsEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current date in millis
|
||||
*
|
||||
* @return the current date in millis
|
||||
*/
|
||||
public long getCurrentDateInTimeMillis() {
|
||||
return mDate.getTimeInMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current date
|
||||
*
|
||||
* @param date The current date in millis
|
||||
*/
|
||||
public void setCurrentDate(long date) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTimeInMillis(date);
|
||||
setCurrentDate(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH),
|
||||
cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current date
|
||||
*
|
||||
* @param year The current year
|
||||
* @param month The current month
|
||||
* @param dayOfMonth The current dayOfMonth
|
||||
* @param hourOfDay The current hourOfDay
|
||||
* @param minute The current minute
|
||||
*/
|
||||
public void setCurrentDate(int year, int month,
|
||||
int dayOfMonth, int hourOfDay, int minute) {
|
||||
setCurrentYear(year);
|
||||
setCurrentMonth(month);
|
||||
setCurrentDay(dayOfMonth);
|
||||
setCurrentHour(hourOfDay);
|
||||
setCurrentMinute(minute);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current year
|
||||
*
|
||||
* @return The current year
|
||||
*/
|
||||
public int getCurrentYear() {
|
||||
return mDate.get(Calendar.YEAR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set current year
|
||||
*
|
||||
* @param year The current year
|
||||
*/
|
||||
public void setCurrentYear(int year) {
|
||||
if (!mInitialising && year == getCurrentYear()) {
|
||||
return;
|
||||
}
|
||||
mDate.set(Calendar.YEAR, year);
|
||||
updateDateControl();
|
||||
onDateTimeChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current month in the year
|
||||
*
|
||||
* @return The current month in the year
|
||||
*/
|
||||
public int getCurrentMonth() {
|
||||
return mDate.get(Calendar.MONTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set current month in the year
|
||||
*
|
||||
* @param month The month in the year
|
||||
*/
|
||||
public void setCurrentMonth(int month) {
|
||||
if (!mInitialising && month == getCurrentMonth()) {
|
||||
return;
|
||||
}
|
||||
mDate.set(Calendar.MONTH, month);
|
||||
updateDateControl();
|
||||
onDateTimeChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current day of the month
|
||||
*
|
||||
* @return The day of the month
|
||||
*/
|
||||
public int getCurrentDay() {
|
||||
return mDate.get(Calendar.DAY_OF_MONTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set current day of the month
|
||||
*
|
||||
* @param dayOfMonth The day of the month
|
||||
*/
|
||||
public void setCurrentDay(int dayOfMonth) {
|
||||
if (!mInitialising && dayOfMonth == getCurrentDay()) {
|
||||
return;
|
||||
}
|
||||
mDate.set(Calendar.DAY_OF_MONTH, dayOfMonth);
|
||||
updateDateControl();
|
||||
onDateTimeChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current hour in 24 hour mode, in the range (0~23)
|
||||
* @return The current hour in 24 hour mode
|
||||
*/
|
||||
public int getCurrentHourOfDay() {
|
||||
return mDate.get(Calendar.HOUR_OF_DAY);
|
||||
}
|
||||
|
||||
private int getCurrentHour() {
|
||||
if (mIs24HourView){
|
||||
return getCurrentHourOfDay();
|
||||
} else {
|
||||
int hour = getCurrentHourOfDay();
|
||||
if (hour > HOURS_IN_HALF_DAY) {
|
||||
return hour - HOURS_IN_HALF_DAY;
|
||||
} else {
|
||||
return hour == 0 ? HOURS_IN_HALF_DAY : hour;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set current hour in 24 hour mode, in the range (0~23)
|
||||
*
|
||||
* @param hourOfDay
|
||||
*/
|
||||
public void setCurrentHour(int hourOfDay) {
|
||||
if (!mInitialising && hourOfDay == getCurrentHourOfDay()) {
|
||||
return;
|
||||
}
|
||||
mDate.set(Calendar.HOUR_OF_DAY, hourOfDay);
|
||||
if (!mIs24HourView) {
|
||||
if (hourOfDay >= HOURS_IN_HALF_DAY) {
|
||||
mIsAm = false;
|
||||
if (hourOfDay > HOURS_IN_HALF_DAY) {
|
||||
hourOfDay -= HOURS_IN_HALF_DAY;
|
||||
}
|
||||
} else {
|
||||
mIsAm = true;
|
||||
if (hourOfDay == 0) {
|
||||
hourOfDay = HOURS_IN_HALF_DAY;
|
||||
}
|
||||
}
|
||||
updateAmPmControl();
|
||||
}
|
||||
mHourSpinner.setValue(hourOfDay);
|
||||
onDateTimeChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get currentMinute
|
||||
*
|
||||
* @return The Current Minute
|
||||
*/
|
||||
public int getCurrentMinute() {
|
||||
return mDate.get(Calendar.MINUTE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set current minute
|
||||
*/
|
||||
public void setCurrentMinute(int minute) {
|
||||
if (!mInitialising && minute == getCurrentMinute()) {
|
||||
return;
|
||||
}
|
||||
mMinuteSpinner.setValue(minute);
|
||||
mDate.set(Calendar.MINUTE, minute);
|
||||
onDateTimeChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if this is in 24 hour view else false.
|
||||
*/
|
||||
public boolean is24HourView () {
|
||||
return mIs24HourView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether in 24 hour or AM/PM mode.
|
||||
*
|
||||
* @param is24HourView True for 24 hour mode. False for AM/PM mode.
|
||||
*/
|
||||
public void set24HourView(boolean is24HourView) {
|
||||
if (mIs24HourView == is24HourView) {
|
||||
return;
|
||||
}
|
||||
mIs24HourView = is24HourView;
|
||||
mAmPmSpinner.setVisibility(is24HourView ? View.GONE : View.VISIBLE);
|
||||
int hour = getCurrentHourOfDay();
|
||||
updateHourControl();
|
||||
setCurrentHour(hour);
|
||||
updateAmPmControl();
|
||||
}
|
||||
|
||||
private void updateDateControl() {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTimeInMillis(mDate.getTimeInMillis());
|
||||
cal.add(Calendar.DAY_OF_YEAR, -DAYS_IN_ALL_WEEK / 2 - 1);
|
||||
mDateSpinner.setDisplayedValues(null);
|
||||
for (int i = 0; i < DAYS_IN_ALL_WEEK; ++i) {
|
||||
cal.add(Calendar.DAY_OF_YEAR, 1);
|
||||
mDateDisplayValues[i] = (String) DateFormat.format("MM.dd EEEE", cal);
|
||||
}
|
||||
mDateSpinner.setDisplayedValues(mDateDisplayValues);
|
||||
mDateSpinner.setValue(DAYS_IN_ALL_WEEK / 2);
|
||||
mDateSpinner.invalidate();
|
||||
}
|
||||
|
||||
private void updateAmPmControl() {
|
||||
if (mIs24HourView) {
|
||||
mAmPmSpinner.setVisibility(View.GONE);
|
||||
} else {
|
||||
int index = mIsAm ? Calendar.AM : Calendar.PM;
|
||||
mAmPmSpinner.setValue(index);
|
||||
mAmPmSpinner.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateHourControl() {
|
||||
if (mIs24HourView) {
|
||||
mHourSpinner.setMinValue(HOUR_SPINNER_MIN_VAL_24_HOUR_VIEW);
|
||||
mHourSpinner.setMaxValue(HOUR_SPINNER_MAX_VAL_24_HOUR_VIEW);
|
||||
} else {
|
||||
mHourSpinner.setMinValue(HOUR_SPINNER_MIN_VAL_12_HOUR_VIEW);
|
||||
mHourSpinner.setMaxValue(HOUR_SPINNER_MAX_VAL_12_HOUR_VIEW);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the callback that indicates the 'Set' button has been pressed.
|
||||
* @param callback the callback, if null will do nothing
|
||||
*/
|
||||
public void setOnDateTimeChangedListener(OnDateTimeChangedListener callback) {
|
||||
mOnDateTimeChangedListener = callback;
|
||||
}
|
||||
|
||||
private void onDateTimeChanged() {
|
||||
if (mOnDateTimeChangedListener != null) {
|
||||
mOnDateTimeChangedListener.onDateTimeChanged(this, getCurrentYear(),
|
||||
getCurrentMonth(), getCurrentDay(), getCurrentHourOfDay(), getCurrentMinute());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.text.format.DateFormat;
|
||||
import android.text.format.DateUtils;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
* Created by htq on 2016/9/13.
|
||||
*/
|
||||
public class DateTimePickerDialog extends AlertDialog implements DialogInterface.OnClickListener {
|
||||
|
||||
private Calendar mDate = Calendar.getInstance();
|
||||
private boolean mIs24HourView;
|
||||
private OnDateTimeSetListener mOnDateTimeSetListener;
|
||||
private DateTimePicker mDateTimePicker;
|
||||
|
||||
public interface OnDateTimeSetListener {
|
||||
void OnDateTimeSet(AlertDialog dialog, long date);
|
||||
}
|
||||
|
||||
public DateTimePickerDialog(Context context, long date) {
|
||||
super(context);
|
||||
mDateTimePicker = new DateTimePicker(context);
|
||||
setView(mDateTimePicker);
|
||||
mDateTimePicker.setOnDateTimeChangedListener(new DateTimePicker.OnDateTimeChangedListener() {
|
||||
public void onDateTimeChanged(DateTimePicker view, int year, int month,
|
||||
int dayOfMonth, int hourOfDay, int minute) {
|
||||
mDate.set(Calendar.YEAR, year);
|
||||
mDate.set(Calendar.MONTH, month);
|
||||
mDate.set(Calendar.DAY_OF_MONTH, dayOfMonth);
|
||||
mDate.set(Calendar.HOUR_OF_DAY, hourOfDay);
|
||||
mDate.set(Calendar.MINUTE, minute);
|
||||
updateTitle(mDate.getTimeInMillis());
|
||||
}
|
||||
});
|
||||
mDate.setTimeInMillis(date);
|
||||
mDate.set(Calendar.SECOND, 0);
|
||||
mDateTimePicker.setCurrentDate(mDate.getTimeInMillis());
|
||||
setButton(context.getString(R.string.datetime_dialog_ok), this);
|
||||
setButton2(context.getString(R.string.datetime_dialog_cancel), (OnClickListener) null);
|
||||
set24HourView(DateFormat.is24HourFormat(this.getContext()));
|
||||
updateTitle(mDate.getTimeInMillis());
|
||||
}
|
||||
|
||||
public void set24HourView(boolean is24HourView) {
|
||||
mIs24HourView = is24HourView;
|
||||
}
|
||||
|
||||
public void setOnDateTimeSetListener(OnDateTimeSetListener callBack) {
|
||||
mOnDateTimeSetListener = callBack;
|
||||
}
|
||||
|
||||
private void updateTitle(long date) {
|
||||
int flag =
|
||||
DateUtils.FORMAT_SHOW_YEAR |
|
||||
DateUtils.FORMAT_SHOW_DATE |
|
||||
DateUtils.FORMAT_SHOW_TIME;
|
||||
flag |= mIs24HourView ? DateUtils.FORMAT_24HOUR : DateUtils.FORMAT_24HOUR;
|
||||
setTitle(DateUtils.formatDateTime(this.getContext(), date, flag));
|
||||
}
|
||||
|
||||
public void onClick(DialogInterface arg0, int arg1) {
|
||||
if (mOnDateTimeSetListener != null) {
|
||||
mOnDateTimeSetListener.OnDateTimeSet(this, mDate.getTimeInMillis());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
|
||||
public class FloatWindowActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_float_window);
|
||||
}
|
||||
}
|
|
@ -1,131 +0,0 @@
|
|||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
import com.example.administrator.myapplication.entity.User;
|
||||
import com.example.administrator.myapplication.utils.AccountUtils;
|
||||
import com.example.administrator.myapplication.utils.MD5Util;
|
||||
import com.example.administrator.myapplication.utils.SPUtils;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import cn.bmob.v3.BmobUser;
|
||||
import cn.bmob.v3.listener.SaveListener;
|
||||
|
||||
|
||||
public class LoginActivity extends AppCompatActivity implements View.OnClickListener {
|
||||
|
||||
@BindView(R.id.btn_login)
|
||||
Button loginBtn;
|
||||
@BindView(R.id.btn_register)
|
||||
TextView registerBtn;
|
||||
@BindView(R.id.login_name)
|
||||
EditText loginName;
|
||||
@BindView(R.id.login_pwd)
|
||||
EditText loginPwd;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
/*set it to be full screen*/
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_login);
|
||||
ButterKnife.bind(this);
|
||||
initDrawableSize();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void initDrawableSize()
|
||||
{
|
||||
Drawable accountDraw=getResources().getDrawable(R.drawable.login_icon_account);
|
||||
accountDraw.setBounds(0,0,45,45);
|
||||
Drawable passwordDraw=getResources().getDrawable(R.drawable.login_icon_password);
|
||||
passwordDraw.setBounds(0,0,45,45);
|
||||
loginName.setCompoundDrawables(accountDraw,null,null,null);
|
||||
loginPwd.setCompoundDrawables(passwordDraw,null,null,null);
|
||||
}
|
||||
@OnClick({R.id.btn_login, R.id.btn_register})
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.btn_login:
|
||||
login();
|
||||
break;
|
||||
case R.id.btn_register:
|
||||
goToRegisterActivity();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void login() {
|
||||
final String name=loginName.getText().toString();
|
||||
final String pwd=loginPwd.getText().toString();
|
||||
final ProgressDialog progress = new ProgressDialog(
|
||||
LoginActivity.this);
|
||||
progress.setMessage("正在登陆...");
|
||||
progress.setCanceledOnTouchOutside(false);
|
||||
progress.show();
|
||||
|
||||
User user = new User();
|
||||
user.setUsername(name);
|
||||
user.setPassword(MD5Util.MD5(pwd));
|
||||
|
||||
// user.setPassword(pwd);
|
||||
// Snackbar.make(loginBtn,"登录成功!",Snackbar.LENGTH_SHORT).show();
|
||||
user.login(this, new SaveListener() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
progress.dismiss();
|
||||
// Snackbar.make(loginBtn,"登录成功!",Snackbar.LENGTH_SHORT).show();
|
||||
//将用户信息保存至本地
|
||||
SPUtils.put(LoginActivity.this,"user_name",name);
|
||||
SPUtils.put(LoginActivity.this,"pwd",MD5Util.MD5(pwd));
|
||||
User user2;
|
||||
user2 = BmobUser.getCurrentUser(LoginActivity.this, User.class);
|
||||
//将登陆信息保存本地
|
||||
AccountUtils.saveUserInfos(LoginActivity.this, user2, MD5Util.MD5(pwd));
|
||||
goToHomeActivity();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(int code, String msg) {
|
||||
progress.dismiss();
|
||||
Toast.makeText(LoginActivity.this,msg, Toast.LENGTH_LONG).show();
|
||||
// Snackbar.make(loginBtn,"登录失败!",Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void goToHomeActivity() {
|
||||
|
||||
Intent intent=new Intent(LoginActivity.this,MainActivity.class);
|
||||
startActivity(intent);
|
||||
this.finish();
|
||||
}
|
||||
|
||||
private void goToRegisterActivity() {
|
||||
Intent intent=new Intent(LoginActivity.this,RegisterActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
|
@ -1,268 +0,0 @@
|
|||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.SystemClock;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.design.widget.NavigationView;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.design.widget.TabItem;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v4.view.GravityCompat;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.support.v7.app.ActionBarDrawerToggle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TableLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
import com.example.administrator.myapplication.db.NoteDatabase;
|
||||
import com.example.administrator.myapplication.entity.UpdataEvent;
|
||||
import com.example.administrator.myapplication.entity.User;
|
||||
import com.example.administrator.myapplication.utils.Constants;
|
||||
import com.example.administrator.myapplication.utils.SystemUtils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
public class MainActivity extends AppCompatActivity
|
||||
implements NavigationView.OnNavigationItemSelectedListener {
|
||||
//此处不能定义为全局的,否则在调用changFragment函数时会报java.lang.IllegalStateException: commit already called
|
||||
// private FragmentManager fm=getSupportFragmentManager();
|
||||
// private FragmentTransaction ft=fm.beginTransaction();
|
||||
|
||||
protected FloatingActionButton fab;
|
||||
private boolean isFirstUse;
|
||||
protected DrawerLayout drawer;
|
||||
private long mBackPressedTime=0;
|
||||
private NoteBookFragment noteBookFragment;
|
||||
private ImageView headIcon;
|
||||
private View baseView;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
isFirstUse=new SystemUtils(MainActivity.this).isFirstUse();
|
||||
if(isFirstUse) {
|
||||
initIntruduceData();
|
||||
}
|
||||
initMainFragment();
|
||||
initUi();
|
||||
initHead();
|
||||
initBgPic();
|
||||
// User.refreshAvatarFromLocal(BmobConstants.MyAvatarDir+"avatarIcon.png",headIcon);
|
||||
//注册EventBus
|
||||
EventBus.getDefault().register(this);
|
||||
// Button picView = findViewById(R.id.app_bar_item2);
|
||||
// picView.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View view) {
|
||||
// setContentView(R.layout.pic_view);
|
||||
// }
|
||||
// });
|
||||
|
||||
//
|
||||
// View picView = (View) findViewById(R.id.app_bar_tablayout);
|
||||
// picView.setOnClickListener(new View.OnClickListener(){
|
||||
// @Override
|
||||
// public void onClick(View view) {
|
||||
// Intent intent = new Intent(MainActivity.this,pic_view.class);
|
||||
// startActivity(intent);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
* 用于刷新头像的
|
||||
* @param event
|
||||
*/
|
||||
@Subscribe
|
||||
public void onEventBackgroundThread(UpdataEvent event) {
|
||||
if (event.getType() == UpdataEvent.UPDATE_USER_INFOS) {
|
||||
User.initDefaultAvatar(this,headIcon);
|
||||
Snackbar.make(headIcon,"update",Snackbar.LENGTH_LONG).show();
|
||||
//mPresenter.setUserNickName();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void initUi()
|
||||
{
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
//toolbar.setTitle("hehehe");
|
||||
setSupportActionBar(toolbar);
|
||||
//toolbar.setTitle("hehehe");
|
||||
fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
// toggleActionButton();
|
||||
Intent intent = new Intent(MainActivity.this, NoteEditActivity.class);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt(NoteEditFragment.NOTE_FROMWHERE_KEY,
|
||||
NoteEditFragment.QUICK_DIALOG);
|
||||
intent.putExtra(Constants.BUNDLE_KEY_ARGS, bundle);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
||||
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
||||
drawer.setDrawerListener(toggle);
|
||||
toggle.syncState();
|
||||
|
||||
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
|
||||
navigationView.setNavigationItemSelectedListener(this);
|
||||
|
||||
baseView= navigationView.getHeaderView(0);
|
||||
headIcon= (ImageView)baseView.findViewById(R.id.imageView);
|
||||
|
||||
headIcon.setOnClickListener(headIconOnTouchListener);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private View.OnClickListener headIconOnTouchListener=new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View vt) {
|
||||
|
||||
Intent intent = new Intent(MainActivity.this, UserInfoActivity.class);
|
||||
startActivity(intent);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
private void initBgPic()
|
||||
{
|
||||
|
||||
SystemUtils systemUtils=new SystemUtils(this);
|
||||
String path=systemUtils.getPath();
|
||||
if(path!=null) {
|
||||
Bitmap bitmap = systemUtils.getBitmapByPath(this, path);
|
||||
if (bitmap != null) {
|
||||
drawer.setBackgroundDrawable(new BitmapDrawable(getResources(), bitmap));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
private void initHead()
|
||||
{
|
||||
|
||||
User.initDefaultAvatar(this,headIcon);
|
||||
|
||||
|
||||
}
|
||||
private void initMainFragment()
|
||||
{
|
||||
FragmentManager fm=getSupportFragmentManager();
|
||||
FragmentTransaction ft=fm.beginTransaction();
|
||||
noteBookFragment=new NoteBookFragment();
|
||||
ft.replace(R.id.main_fraglayout, noteBookFragment,null);
|
||||
ft.commit();
|
||||
}
|
||||
|
||||
|
||||
protected void changeFragment(Fragment fragment)
|
||||
{
|
||||
FragmentManager fm=getSupportFragmentManager();
|
||||
FragmentTransaction ft=fm.beginTransaction();
|
||||
ft.replace(R.id.main_fraglayout, fragment,null);
|
||||
// ft.addToBackStack(fragment.toString());
|
||||
ft.commit();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void initIntruduceData()
|
||||
{
|
||||
NoteDatabase noteDb= new NoteDatabase(MainActivity.this);
|
||||
noteDb.insertIntroduce(this);
|
||||
new SystemUtils(MainActivity.this).set("isFirstUse","false");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
if (drawer.isDrawerOpen(GravityCompat.START)) {
|
||||
drawer.closeDrawer(GravityCompat.START);
|
||||
} else {
|
||||
long curTime = SystemClock.uptimeMillis();
|
||||
if ((curTime - mBackPressedTime) < (2 * 1000)) {
|
||||
finish();
|
||||
System.exit(0);
|
||||
} else {
|
||||
mBackPressedTime = curTime;
|
||||
Snackbar.make(drawer, "双击退出程序", Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
// super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings("StatementWithEmptyBody")
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(MenuItem item) {
|
||||
// Handle navigation view item clicks here.
|
||||
int id = item.getItemId();
|
||||
|
||||
if (id == R.id.nav_change_bg) {
|
||||
|
||||
setTitle("更换皮肤");
|
||||
ChangeBgFragment changeBgFragment=new ChangeBgFragment();
|
||||
changeFragment(changeBgFragment);
|
||||
fab.hide();
|
||||
} else if (id == R.id.nav_home) {
|
||||
setTitle("主页");
|
||||
initMainFragment();
|
||||
|
||||
} else if (id == R.id.nav_setting) {
|
||||
setTitle("设置");
|
||||
SettingFragment settingFragment=new SettingFragment();
|
||||
changeFragment(settingFragment);
|
||||
fab.hide();
|
||||
|
||||
} else if (id == R.id.nav_share) {
|
||||
|
||||
SystemUtils.shareApp(this);
|
||||
|
||||
} else if (id == R.id.nav_about) {
|
||||
|
||||
setTitle("关于应用");
|
||||
AboutAppFragment aboutAppFragment=new AboutAppFragment();
|
||||
changeFragment(aboutAppFragment);
|
||||
fab.hide();
|
||||
}
|
||||
else if (id == R.id.nav_exit) {
|
||||
finish();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
drawer.closeDrawer(GravityCompat.START);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,368 +0,0 @@
|
|||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnTouchListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
import com.example.administrator.myapplication.adapter.NotebookAdapter;
|
||||
import com.example.administrator.myapplication.db.NoteDatabase;
|
||||
import com.example.administrator.myapplication.entity.NotebookData;
|
||||
import com.example.administrator.myapplication.entity.OnResponseListener;
|
||||
import com.example.administrator.myapplication.entity.Response;
|
||||
import com.example.administrator.myapplication.entity.User;
|
||||
import com.example.administrator.myapplication.utils.AccountUtils;
|
||||
import com.example.administrator.myapplication.utils.Constants;
|
||||
import com.example.administrator.myapplication.utils.HTQAnimations;
|
||||
import com.example.administrator.myapplication.utils.SystemUtils;
|
||||
import com.example.administrator.myapplication.widget.HTQDragGridView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
|
||||
public class NoteBookFragment extends Fragment implements
|
||||
OnItemClickListener, OnRefreshListener {
|
||||
|
||||
@BindView(R.id.frag_note_list)
|
||||
HTQDragGridView mGrid;
|
||||
@BindView(R.id.frag_note_trash)
|
||||
ImageView mImgTrash;
|
||||
@BindView(R.id.swiperefreshlayout)
|
||||
SwipeRefreshLayout mSwipeRefreshLayout;
|
||||
|
||||
private NoteDatabase noteDb;
|
||||
private List<NotebookData> datas;
|
||||
private NotebookAdapter adapter;
|
||||
private Activity aty;
|
||||
public static final int STATE_NONE = 0;
|
||||
public static final int STATE_REFRESH = 1;
|
||||
public static final int STATE_LOADMORE = 2;
|
||||
public static final int STATE_NOMORE = 3;
|
||||
public static final int STATE_PRESSNONE = 4;// 正在下拉但还没有到刷新的状态
|
||||
public static int mState = STATE_NONE;
|
||||
/**
|
||||
* 用来做更进一步人性化的防手抖策略时使用<br>
|
||||
* 比如由于手抖动上下拉菜单时拉动一部分,但又没有达到可刷新的时候,暂停一段时间,这个时候用户的逻辑应该是要移动item的。<br>
|
||||
* 其实应该还有一种根据setOnFocusChangeListener来改写的方法,我没有尝试。
|
||||
*/
|
||||
// private static final Handler mHandler = new Handler() {
|
||||
// @Override
|
||||
// public void handleMessage(android.os.Message msg) {
|
||||
// mList.setDragEnable(true);
|
||||
// };
|
||||
// };
|
||||
|
||||
/********************************* function method ******************************/
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
super.onCreateView(inflater, container, savedInstanceState);
|
||||
View rootView = inflater.inflate(R.layout.fragment_note, null,
|
||||
false);
|
||||
aty = getActivity();
|
||||
ButterKnife.bind(this, rootView);
|
||||
initData();
|
||||
initView(rootView);
|
||||
if(new SystemUtils(getActivity()).isTarn())
|
||||
mGrid.setAlpha(0.55f);
|
||||
return rootView;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
refurbish();
|
||||
((MainActivity) getActivity()).fab.show();
|
||||
//setListCanPull();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
noteDb.destroy();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position,
|
||||
long id) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt(NoteEditFragment.NOTE_FROMWHERE_KEY,
|
||||
NoteEditFragment.NOTEBOOK_ITEM);
|
||||
bundle.putSerializable(NoteEditFragment.NOTE_KEY, datas.get(position));
|
||||
|
||||
Intent intent=new Intent(getActivity(),NoteEditActivity.class);
|
||||
intent.putExtra(Constants.BUNDLE_KEY_ARGS, bundle);
|
||||
startActivity(intent);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/***************************** initialization method ***************************/
|
||||
|
||||
|
||||
public void initData() {
|
||||
noteDb = new NoteDatabase(aty);
|
||||
datas = noteDb.query();// 查询操作,忽略耗时
|
||||
if (datas != null) {
|
||||
adapter = new NotebookAdapter(aty, datas);
|
||||
}
|
||||
else //如果本地无数据则尝试从服务器端获取数据
|
||||
{
|
||||
getServerData();
|
||||
}
|
||||
}
|
||||
|
||||
public void getServerData()
|
||||
{
|
||||
String userId = AccountUtils.getUserId(getActivity());
|
||||
User.getUserNotes(getActivity(), userId, new OnResponseListener() {
|
||||
@Override
|
||||
public void onResponse(Response response) {
|
||||
if(response.isSucces())
|
||||
{
|
||||
datas.clear();//先将datas中的数据全部清除掉
|
||||
datas.addAll(response.getNoteItemList());
|
||||
if (datas.size() > 0) {
|
||||
adapter = new NotebookAdapter(aty, datas);
|
||||
|
||||
} else {
|
||||
Snackbar.make(mGrid,"暂无数据哦!赶快添加一个:)", Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void initView(View view) {
|
||||
mGrid.setAdapter(adapter);
|
||||
mGrid.setOnItemClickListener(this);
|
||||
mGrid.setTrashView(mImgTrash);
|
||||
mGrid.setSelector(new ColorDrawable(Color.TRANSPARENT));
|
||||
mGrid.setOnDeleteListener(new HTQDragGridView.OnDeleteListener() {
|
||||
@Override
|
||||
public void onDelete(final int position) {
|
||||
|
||||
|
||||
// datas.get(position).setObjectId(datas.get(position).getObjectId());
|
||||
datas.get(position).deleteNoteInServe(getActivity(), new OnResponseListener() {
|
||||
@Override
|
||||
public void onResponse(Response response) {
|
||||
if(!response.isSucces())
|
||||
{
|
||||
Toast.makeText(getActivity(),response.getMsg(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
delete(position);
|
||||
}
|
||||
});
|
||||
mGrid.setOnMoveListener(new HTQDragGridView.OnMoveListener() {
|
||||
@Override
|
||||
public void startMove() {
|
||||
mSwipeRefreshLayout.setEnabled(false);
|
||||
mImgTrash.startAnimation(HTQAnimations.getTranslateAnimation(0,
|
||||
0, mImgTrash.getTop(), 0, 500));
|
||||
mImgTrash.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishMove() {
|
||||
// setListCanPull();
|
||||
mImgTrash.setVisibility(View.INVISIBLE);
|
||||
mImgTrash.startAnimation(HTQAnimations.getTranslateAnimation(0,
|
||||
0, 0, mImgTrash.getTop(), 500));
|
||||
if (adapter.getDataChange()) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
noteDb.reset(adapter.getDatas());
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancleMove() {}
|
||||
});
|
||||
|
||||
|
||||
mSwipeRefreshLayout.setOnTouchListener(new OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_MOVE) {
|
||||
mState = STATE_PRESSNONE;
|
||||
mGrid.setDragEnable(false);
|
||||
// mHandler.sendMessageDelayed(Message.obtain(), 400);
|
||||
} else {
|
||||
mGrid.setDragEnable(true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
mSwipeRefreshLayout.setOnRefreshListener(this);
|
||||
mSwipeRefreshLayout.setColorSchemeResources(
|
||||
R.color.swiperefresh_color1, R.color.swiperefresh_color2,
|
||||
R.color.swiperefresh_color3, R.color.swiperefresh_color4);
|
||||
// mEmptyLayout.setErrorType(EmptyLayout.NODATA);
|
||||
// if (!datas.isEmpty()) {
|
||||
// mEmptyLayout.setVisibility(View.GONE);
|
||||
// }
|
||||
}
|
||||
|
||||
/********************************* GridView method ******************************/
|
||||
|
||||
@Override
|
||||
public void onRefresh() {//同步数据,先从服务器端获取数据,然后重置到数据库中
|
||||
if (mState == STATE_REFRESH) {
|
||||
return;
|
||||
}
|
||||
// 设置顶部正在刷新
|
||||
mGrid.setSelection(0);
|
||||
setSwipeRefreshLoadingState();
|
||||
getServerData();
|
||||
adapter.refurbishData(datas);
|
||||
noteDb.reset(datas);//将结果重置到数据库
|
||||
for(int i=0;i<datas.size();i++)
|
||||
{
|
||||
|
||||
noteDb.save(datas.get(i));
|
||||
}
|
||||
|
||||
refurbish();
|
||||
setSwipeRefreshLoadedState();
|
||||
Snackbar.make(mGrid, "已从服务器端同步数据!", Snackbar.LENGTH_LONG)
|
||||
.setAction("Action", null).show();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置顶部正在加载的状态
|
||||
*/
|
||||
private void setSwipeRefreshLoadingState() {
|
||||
mState = STATE_REFRESH;
|
||||
mGrid.setDragEnable(false);
|
||||
if (mSwipeRefreshLayout != null) {
|
||||
mSwipeRefreshLayout.setRefreshing(true);
|
||||
// 防止多次重复刷新
|
||||
// mSwipeRefreshLayout.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置顶部加载完毕的状态
|
||||
*/
|
||||
private void setSwipeRefreshLoadedState() {
|
||||
mState = STATE_NOMORE;
|
||||
if (mSwipeRefreshLayout != null) {
|
||||
mSwipeRefreshLayout.setRefreshing(false);
|
||||
mSwipeRefreshLayout.setEnabled(true);
|
||||
}
|
||||
mGrid.setDragEnable(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/********************************* synchronize method ******************************/
|
||||
|
||||
/**
|
||||
* 使用自带缓存功能的网络请求,防止多次刷新造成的流量损耗以及服务器压力
|
||||
*/
|
||||
private void refurbish() {
|
||||
datas = noteDb.query();
|
||||
if (datas != null) {
|
||||
if (adapter != null) {
|
||||
adapter.refurbishData(datas);
|
||||
} else {
|
||||
adapter = new NotebookAdapter(aty, datas);
|
||||
mGrid.setAdapter(adapter);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
*
|
||||
* @param index
|
||||
*/
|
||||
private void delete(int index) {
|
||||
final int noteId = datas.get(index).getId();
|
||||
|
||||
noteDb.delete(noteId);
|
||||
datas.remove(index);
|
||||
if (datas != null && adapter != null) {
|
||||
adapter.refurbishData(datas);
|
||||
|
||||
mGrid.setAdapter(adapter);
|
||||
}
|
||||
|
||||
// updateEmptyView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
//搜索显示框
|
||||
inflater.inflate(R.menu.main, menu);
|
||||
MenuItem searchViewbtn = (MenuItem) menu.findItem(R.id.action_search);
|
||||
//System.out.println("123456");
|
||||
searchViewbtn.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
Intent intent = new Intent(getActivity(),NoteSearchActivity.class);
|
||||
startActivity(intent);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// // Handle action bar item clicks here. The action bar will
|
||||
// // automatically handle clicks on the Home/Up button, so long
|
||||
// // as you specify a parent activity in AndroidManifest.xml.
|
||||
// int id = item.getItemId();
|
||||
//
|
||||
// //noinspection SimplifiableIfStatement
|
||||
// if (id == R.id.action_settings) {
|
||||
// new SystemUtils(getActivity()).setBoolean("isTran",true);
|
||||
// mGrid.setAlpha(0.55f);
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// return super.onOptionsItemSelected(item);
|
||||
// }
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
|
||||
|
||||
public class NoteEditActivity extends AppCompatActivity {
|
||||
|
||||
|
||||
private NoteEditFragment noteEditFragment;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_note_edit);
|
||||
setTitle("添加记录");
|
||||
initFragment();
|
||||
|
||||
}
|
||||
|
||||
private void initFragment()
|
||||
{
|
||||
FragmentManager fm=getSupportFragmentManager();
|
||||
FragmentTransaction ft=fm.beginTransaction();
|
||||
noteEditFragment=new NoteEditFragment();
|
||||
ft.replace(R.id.main_fraglayout, noteEditFragment,null);
|
||||
ft.commit();
|
||||
}
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
|
||||
if(!noteEditFragment.onBackPressed())
|
||||
super.onBackPressed();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,490 +0,0 @@
|
|||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
|
||||
import android.app.AlarmManager;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.text.Html;
|
||||
import android.text.InputType;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.github.clans.fab.FloatingActionButton;
|
||||
import com.example.administrator.myapplication.R;
|
||||
import com.example.administrator.myapplication.db.NoteDatabase;
|
||||
import com.example.administrator.myapplication.entity.NotebookData;
|
||||
import com.example.administrator.myapplication.entity.OnResponseListener;
|
||||
import com.example.administrator.myapplication.entity.Response;
|
||||
import com.example.administrator.myapplication.utils.AccountUtils;
|
||||
import com.example.administrator.myapplication.utils.Constants;
|
||||
import com.example.administrator.myapplication.utils.DialogHelp;
|
||||
import com.example.administrator.myapplication.utils.HTQAnimations;
|
||||
import com.example.administrator.myapplication.utils.ResourceParser;
|
||||
import com.example.administrator.myapplication.utils.SPUtils;
|
||||
import com.example.administrator.myapplication.utils.StringUtils;
|
||||
import com.example.administrator.myapplication.utils.SystemUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
|
||||
public class NoteEditFragment extends Fragment implements View.OnClickListener,View.OnTouchListener {
|
||||
@BindView(R.id.note_detail_edit)
|
||||
EditText mEtContent;
|
||||
@BindView(R.id.note_detail_tv_date)
|
||||
TextView mTvDate;
|
||||
@BindView(R.id.note_detail_titlebar)
|
||||
RelativeLayout mLayoutTitle;
|
||||
@BindView(R.id.note_detail_img_thumbtack)
|
||||
ImageView mImgThumbtack;
|
||||
|
||||
@BindView(R.id.note_detail_img_button)
|
||||
ImageView mImgMenu;
|
||||
@BindView(R.id.note_detail_menu)
|
||||
RelativeLayout mLayoutMenu;
|
||||
|
||||
@BindView(R.id.note_detail_img_green)
|
||||
ImageView mImgGreen;
|
||||
@BindView(R.id.note_detail_img_blue)
|
||||
ImageView mImgBlue;
|
||||
@BindView(R.id.note_detail_img_purple)
|
||||
ImageView mImgPurple;
|
||||
@BindView(R.id.note_detail_img_yellow)
|
||||
ImageView mImgYellow;
|
||||
@BindView(R.id.note_detail_img_red)
|
||||
ImageView mImgRed;
|
||||
|
||||
@BindView(R.id.menu_item_text_font)
|
||||
FloatingActionButton menuTextFont;
|
||||
@BindView(R.id.menu_item_clock)
|
||||
FloatingActionButton menuClock;
|
||||
@BindView(R.id.menu_item_desktop)
|
||||
FloatingActionButton menuDesktop;
|
||||
@BindView(R.id.menu_item_share)
|
||||
FloatingActionButton menuShare;
|
||||
|
||||
@BindView(R.id.font_size_selector)
|
||||
View mFontSizeSelector;
|
||||
private NotebookData editData;
|
||||
private NoteDatabase noteDb;
|
||||
protected boolean isNewNote;
|
||||
private int whereFrom = QUICK_DIALOG;// 从哪个界面来
|
||||
|
||||
public static final String NOTE_KEY = "notebook_key";
|
||||
public static final String NOTE_FROMWHERE_KEY = "fromwhere_key";
|
||||
public static final int QUICK_DIALOG = 0;
|
||||
public static final int NOTEBOOK_ITEM = 1;
|
||||
public static final String DESKTOP = "desktop";
|
||||
|
||||
|
||||
private int mFontSizeId;
|
||||
private static final Map<Integer, Integer> sFontSelectorSelectionMap = new HashMap<Integer, Integer>();
|
||||
|
||||
static {
|
||||
sFontSelectorSelectionMap.put(Constants.TEXT_LARGE, R.id.iv_large_select);
|
||||
sFontSelectorSelectionMap.put(Constants.TEXT_SMALL, R.id.iv_small_select);
|
||||
sFontSelectorSelectionMap.put(Constants.TEXT_MEDIUM, R.id.iv_medium_select);
|
||||
sFontSelectorSelectionMap.put(Constants.TEXT_SUPER, R.id.iv_super_select);
|
||||
}
|
||||
|
||||
private static final Map<Integer, Integer> sFontSizeBtnsMap = new HashMap<Integer, Integer>();
|
||||
|
||||
static {
|
||||
sFontSizeBtnsMap.put(R.id.ll_font_large, Constants.TEXT_LARGE);
|
||||
sFontSizeBtnsMap.put(R.id.ll_font_small, Constants.TEXT_SMALL);
|
||||
sFontSizeBtnsMap.put(R.id.ll_font_normal,Constants.TEXT_MEDIUM);
|
||||
sFontSizeBtnsMap.put(R.id.ll_font_super, Constants.TEXT_SUPER);
|
||||
}
|
||||
public static final int[] sBackGrounds = { 0xffe5fce8,// 绿色
|
||||
0xfffffdd7,// 黄色
|
||||
0xffffddde,// 红色
|
||||
0xffccf2fd,// 蓝色
|
||||
0xfff7f5f6,// 紫色
|
||||
};
|
||||
public static final int[] sTitleBackGrounds = { 0xffcef3d4,// 绿色
|
||||
0xffebe5a9,// 黄色
|
||||
0xffecc4c3,// 红色
|
||||
0xffa9d5e2,// 蓝色
|
||||
0xffddd7d9,// 紫色
|
||||
};
|
||||
|
||||
public static final int[] sThumbtackImgs = { R.drawable.green,
|
||||
R.drawable.yellow, R.drawable.red, R.drawable.blue,
|
||||
R.drawable.purple };
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
super.onCreateView(inflater, container, savedInstanceState);
|
||||
View rootView = inflater.inflate(R.layout.note_edit_fraglayout,
|
||||
container, false);
|
||||
ButterKnife.bind(this, rootView);
|
||||
initData();
|
||||
initView(rootView);
|
||||
|
||||
return rootView;
|
||||
}
|
||||
|
||||
|
||||
private void initView(View view) {
|
||||
|
||||
mImgGreen.setOnClickListener(this);
|
||||
mImgBlue.setOnClickListener(this);
|
||||
mImgPurple.setOnClickListener(this);
|
||||
mImgYellow.setOnClickListener(this);
|
||||
mImgRed.setOnClickListener(this);
|
||||
|
||||
mEtContent.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE);
|
||||
mEtContent.setSingleLine(false);
|
||||
mEtContent.setHorizontallyScrolling(false);
|
||||
mEtContent.setText(Html.fromHtml(editData.getContent()).toString());
|
||||
mTvDate.setText(editData.getDate());
|
||||
|
||||
mEtContent.setBackgroundColor(sBackGrounds[editData.getColor()]);
|
||||
mLayoutTitle.setBackgroundColor(sTitleBackGrounds[editData.getColor()]);
|
||||
mImgThumbtack.setImageResource(sThumbtackImgs[editData.getColor()]);
|
||||
|
||||
mImgMenu.setOnTouchListener(this);
|
||||
mLayoutMenu.setOnTouchListener(this);
|
||||
|
||||
// mImgThumbtack.setImageResource(sThumbtackImgs[editData.getColor()]);
|
||||
// mEtContent.setBackgroundColor(sBackGrounds[editData.getColor()]);
|
||||
// mLayoutTitle.setBackgroundColor(sTitleBackGrounds[editData.getColor()]);
|
||||
// closeMenu();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void initData() {
|
||||
//System.out.println("initData!\n");
|
||||
noteDb = new NoteDatabase(getActivity());
|
||||
if (editData == null) {
|
||||
editData = new NotebookData();
|
||||
editData.setContent(new SystemUtils(getActivity()).getNoteDraft());
|
||||
isNewNote = true;
|
||||
}
|
||||
if (StringUtils.isEmpty(editData.getDate())) {
|
||||
editData.setDate(StringUtils.getDataTime("yyyy/MM/dd"));
|
||||
}
|
||||
|
||||
mFontSizeId= (int) SPUtils.get(getActivity(),Constants.TEXT_SIZE,Constants.TEXT_MEDIUM);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.note_detail_img_green:
|
||||
editData.setColor(0);
|
||||
break;
|
||||
case R.id.note_detail_img_blue:
|
||||
editData.setColor(3);
|
||||
break;
|
||||
case R.id.note_detail_img_purple:
|
||||
editData.setColor(4);
|
||||
break;
|
||||
case R.id.note_detail_img_yellow:
|
||||
editData.setColor(1);
|
||||
break;
|
||||
case R.id.note_detail_img_red:
|
||||
editData.setColor(2);
|
||||
break;
|
||||
|
||||
}
|
||||
mImgThumbtack.setImageResource(sThumbtackImgs[editData.getColor()]);
|
||||
mEtContent.setBackgroundColor(sBackGrounds[editData.getColor()]);
|
||||
mLayoutTitle.setBackgroundColor(sTitleBackGrounds[editData.getColor()]);
|
||||
closeMenu();
|
||||
}
|
||||
|
||||
@OnClick({R.id.menu_item_share,R.id.menu_item_text_font,R.id.menu_item_clock,R.id.menu_item_desktop})
|
||||
public void click( FloatingActionButton menuItem)
|
||||
{
|
||||
String editContent=mEtContent.getText().toString();
|
||||
switch(menuItem.getId())
|
||||
{
|
||||
case R.id.menu_item_share:{
|
||||
|
||||
if(editContent.equals(""))
|
||||
{
|
||||
Toast.makeText(getActivity(),"您还未输入内容哦", Toast.LENGTH_LONG).show();
|
||||
}else {
|
||||
SystemUtils.shareNote(getActivity(),editContent);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case R.id.menu_item_text_font:{
|
||||
showTextSelectorPanel();
|
||||
|
||||
} break;
|
||||
case R.id.menu_item_clock:{
|
||||
if(!editContent.equals("")) {
|
||||
setReminder(editContent);
|
||||
}
|
||||
else
|
||||
{
|
||||
Toast.makeText(getActivity(),"亲,内容为空哦", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
} break;
|
||||
|
||||
case R.id.menu_item_desktop:{
|
||||
|
||||
if(!editContent.equals("")) {
|
||||
addToDesktop(editContent);
|
||||
}
|
||||
else
|
||||
{
|
||||
Toast.makeText(getActivity(),"内容为空,添加失败", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@OnClick({R.id.ll_font_small,R.id.ll_font_normal,R.id.ll_font_large,R.id.ll_font_super})
|
||||
public void ClickTextSizeSelector(View v) {
|
||||
int id = v.getId();
|
||||
getActivity().findViewById(sFontSelectorSelectionMap.get(mFontSizeId)).setVisibility(View.GONE);
|
||||
mFontSizeId = sFontSizeBtnsMap.get(id);
|
||||
SPUtils.put(getActivity(),Constants.TEXT_SIZE,mFontSizeId);
|
||||
getActivity().findViewById(sFontSelectorSelectionMap.get(mFontSizeId)).setVisibility(View.VISIBLE);
|
||||
mEtContent.setTextAppearance(getActivity(),
|
||||
ResourceParser.TextAppearanceResources.getTexAppearanceResource(mFontSizeId));
|
||||
getActivity().findViewById(R.id.font_size_selector).setVisibility(View.GONE);
|
||||
|
||||
}
|
||||
private void showTextSelectorPanel() {
|
||||
mFontSizeSelector.setVisibility(View.VISIBLE);
|
||||
getActivity().findViewById(sFontSelectorSelectionMap.get(mFontSizeId)).setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private void addToDesktop(String title) {
|
||||
Intent intent = new Intent();
|
||||
Intent shortcutIntent = new Intent(getActivity(), NoteEditActivity.class);
|
||||
// SPUtils.put(getActivity(),DESKTOP,title);//将内容保存至share中
|
||||
shortcutIntent.putExtra(DESKTOP,title);
|
||||
shortcutIntent.setAction(Intent.ACTION_VIEW);
|
||||
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
|
||||
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME,title);
|
||||
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
|
||||
Intent.ShortcutIconResource.fromContext(getActivity(), R.mipmap.app_icon));
|
||||
intent.putExtra("duplicate", true);
|
||||
intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
|
||||
Toast.makeText(getActivity(),"已添加至桌面", Toast.LENGTH_LONG).show();
|
||||
// showToast(R.string.info_note_enter_desktop);
|
||||
getActivity().sendBroadcast(intent);
|
||||
}
|
||||
|
||||
private void setReminder(final String str) {
|
||||
DateTimePickerDialog d = new DateTimePickerDialog(getActivity(), System.currentTimeMillis());
|
||||
d.setOnDateTimeSetListener(new DateTimePickerDialog.OnDateTimeSetListener() {
|
||||
public void OnDateTimeSet(AlertDialog dialog, long date) {
|
||||
setClock(date, true,str);
|
||||
// mEditNote.setAlertDate(date, true);
|
||||
}
|
||||
});
|
||||
d.show();
|
||||
}
|
||||
|
||||
private void setClock(Long date, boolean set, String str)
|
||||
{
|
||||
|
||||
Intent intent = new Intent(getActivity(), AlarmReceiver.class);
|
||||
intent.putExtra(Constants.ALART_CONTENT,str);
|
||||
// intent.setData(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, mWorkingNote.getNoteId()));
|
||||
PendingIntent pendingIntent = PendingIntent.getBroadcast(getActivity(), 0, intent, 0);
|
||||
AlarmManager alarmManager = ((AlarmManager) getActivity().getSystemService(getActivity().ALARM_SERVICE));
|
||||
if (!set) {
|
||||
alarmManager.cancel(pendingIntent);
|
||||
} else {
|
||||
alarmManager.set(AlarmManager.RTC_WAKEUP, date, pendingIntent);
|
||||
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (MotionEvent.ACTION_DOWN == event.getAction()) {
|
||||
if (mLayoutMenu.getVisibility() == View.GONE) {
|
||||
openMenu();
|
||||
} else {
|
||||
closeMenu();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* 切换便签颜色的菜单
|
||||
*/
|
||||
private void openMenu() {
|
||||
HTQAnimations.openAnimation(mLayoutMenu, mImgMenu, 700);
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换便签颜色的菜单
|
||||
*/
|
||||
private void closeMenu() {
|
||||
HTQAnimations.closeAnimation(mLayoutMenu, mImgMenu, 500);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存已编辑内容到数据库
|
||||
*/
|
||||
private void save() {
|
||||
setNoteProperty();
|
||||
noteDb.save(editData);
|
||||
}
|
||||
private void setNoteProperty()
|
||||
{
|
||||
//System.out.println("setNoteProperty!\n");
|
||||
if (editData.getId() == 0) {
|
||||
editData.setId(-1
|
||||
* StringUtils.toInt(
|
||||
StringUtils.getDataTime("dddHHmmss"), 0));
|
||||
}
|
||||
String userId = AccountUtils.getUserId(getActivity());
|
||||
editData.setUserId(userId);
|
||||
|
||||
editData.setUnixTime(StringUtils.getDataTime("yyyy-MM-dd HH:mm:ss"));
|
||||
editData.setContent(mEtContent.getText().toString());
|
||||
editData.setObjectId(editData.getObjectId());
|
||||
}
|
||||
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setHasOptionsMenu(true);
|
||||
//System.out.println("onCreate!");
|
||||
Bundle bundle = getActivity().getIntent().getBundleExtra(Constants.BUNDLE_KEY_ARGS);
|
||||
if (bundle != null) {
|
||||
editData = (NotebookData) bundle.getSerializable(NOTE_KEY);
|
||||
whereFrom = bundle.getInt(NOTE_FROMWHERE_KEY, QUICK_DIALOG);
|
||||
}
|
||||
getActivity().getWindow().setSoftInputMode(
|
||||
WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN
|
||||
| WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
String desktopStr=getActivity().getIntent().getStringExtra(DESKTOP);
|
||||
|
||||
if(desktopStr!=null)//表明用户从桌面快捷方式点击过来的
|
||||
{
|
||||
mEtContent.setText(desktopStr);
|
||||
}
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.notebook_edit_menu, menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.public_menu_send:
|
||||
if (!StringUtils.isEmpty(mEtContent.getText().toString())) {
|
||||
save();
|
||||
|
||||
if(whereFrom==0) {//表明用户是从主机面的加号按钮跳转过来
|
||||
editData.postNoteToServer(getActivity(), new OnResponseListener() {
|
||||
@Override
|
||||
public void onResponse(Response response) {
|
||||
if (!response.isSucces()) {
|
||||
Snackbar.make(mImgGreen, "保存至服务器端失败,暂保存在本地", Snackbar.LENGTH_LONG).show();
|
||||
} else {
|
||||
|
||||
getActivity().finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
}else if(whereFrom==1)//表明用户是从主界面的item跳转过来,此时只需更新即可
|
||||
{
|
||||
editData.updateNoteInServe(getActivity(), editData.getObjectId(), new OnResponseListener() {
|
||||
@Override
|
||||
public void onResponse(Response response) {
|
||||
if (!response.isSucces()) {
|
||||
Snackbar.make(mImgGreen, "保存至服务器端失败"+response.getMsg(), Snackbar.LENGTH_LONG).show();
|
||||
} else {
|
||||
getActivity().finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean onBackPressed() {
|
||||
if (isNewNote) {
|
||||
final String content = mEtContent.getText().toString();
|
||||
if (!TextUtils.isEmpty(content)) {
|
||||
DialogHelp.getConfirmDialog(getActivity(), "是否保存为草稿?", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
//
|
||||
new SystemUtils(getActivity()).setNoteDraft(content+"[草稿]");
|
||||
getActivity().finish();
|
||||
}
|
||||
}, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
new SystemUtils(getActivity()).setNoteDraft("");
|
||||
getActivity().finish();
|
||||
}
|
||||
}).show();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* notice :inner Broadcast receiver must be static ( to be registered through Manifest)
|
||||
* or Non-static broadcast receiver must be registered and unregistered inside the Parent class
|
||||
*
|
||||
*/
|
||||
public static class AlarmReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
intent.setClass(context, AlarmAlertActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
// Log.i("alarm content",intent.getStringExtra(Constants.ALART_CONTENT));
|
||||
//intent.putExtra(Constants.ALART_CONTENT,intent.getStringExtra(Constants.ALART_CONTENT));
|
||||
context.startActivity(intent);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.LinearLayoutCompat;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
|
||||
import static com.example.administrator.myapplication.R.*;
|
||||
import static com.example.administrator.myapplication.R.id.imageView2;
|
||||
|
||||
public class NoteSearchActivity extends AppCompatActivity {
|
||||
public static ImageView img;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(layout.activity_note_search);
|
||||
img = (ImageView)this.findViewById(id.search_img);
|
||||
final int[] tmp = {0};
|
||||
//System.out.println(img);
|
||||
Button searchNotebtn = (Button)findViewById(id.btn_article_search);
|
||||
searchNotebtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
//System.out.println(img);
|
||||
if(tmp[0] ==0) {
|
||||
img.setVisibility(View.VISIBLE);
|
||||
tmp[0]++;
|
||||
}
|
||||
else{
|
||||
img.setImageDrawable(getResources().getDrawable((drawable.sch1)));
|
||||
img.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,119 +0,0 @@
|
|||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.text.TextUtils;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
import com.example.administrator.myapplication.entity.User;
|
||||
import com.example.administrator.myapplication.utils.MD5Util;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import cn.bmob.v3.listener.SaveListener;
|
||||
|
||||
/**
|
||||
* Created by htq on 2016/9/4.
|
||||
*/
|
||||
public class RegisterActivity extends AppCompatActivity {
|
||||
|
||||
@BindView(R.id.et_username)
|
||||
EditText accountEt;
|
||||
@BindView(R.id.et_password)
|
||||
EditText pwdEt;
|
||||
@BindView(R.id.et_email)
|
||||
EditText twicePwdEt;
|
||||
@BindView(R.id.btn_register)
|
||||
Button registerBtn;
|
||||
@BindView(R.id.img_back)
|
||||
ImageButton imgBtnBack;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// // requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
// /*set it to be full screen*/
|
||||
// getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
// WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_register);
|
||||
ButterKnife.bind(this);
|
||||
}
|
||||
|
||||
@OnClick(R.id.img_back)
|
||||
public void back() {
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
@OnClick(R.id.btn_register)
|
||||
public void register(){
|
||||
String name =accountEt.getText().toString();
|
||||
String password = pwdEt.getText().toString();
|
||||
String pwd_again = twicePwdEt.getText().toString();
|
||||
|
||||
if (TextUtils.isEmpty(name)) {
|
||||
Snackbar.make(registerBtn,"账号不能为空", Snackbar.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(password)) {
|
||||
Snackbar.make(registerBtn,"密码不能为空", Snackbar.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
if (!pwd_again.equals(password)) {
|
||||
Snackbar.make(registerBtn,"两次密码输入不一致", Snackbar.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
boolean isNetConnected = com.example.administrator.myapplication.utils.CommonUtils.isNetworkAvailable(this);
|
||||
if(!isNetConnected){
|
||||
Snackbar.make(registerBtn,"网络连接出错", Snackbar.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
final ProgressDialog progress = new ProgressDialog(RegisterActivity.this);
|
||||
progress.setMessage("正在注册...");
|
||||
progress.setCanceledOnTouchOutside(false);
|
||||
progress.show();
|
||||
//由于每个应用的注册所需的资料都不一样,故IM sdk未提供注册方法,用户可按照bmod SDK的注册方式进行注册。
|
||||
//注册的时候需要注意两点:1、User表中绑定设备id和type,2、设备表中绑定username字段
|
||||
final User bu = new User();
|
||||
bu.setUsername(name);
|
||||
bu.setPassword(MD5Util.MD5(password));
|
||||
//将user和设备id进行绑定aa
|
||||
// bu.setUserSex(true);
|
||||
// bu.setDeviceType("android");
|
||||
// bu.setInstallId(BmobInstallation.getInstallationId(this));
|
||||
bu.signUp(RegisterActivity.this, new SaveListener() {
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
// TODO Auto-generated method stub
|
||||
progress.dismiss();
|
||||
Snackbar.make(registerBtn,"注册成功", Snackbar.LENGTH_LONG).show();
|
||||
// 将设备与username进行绑定
|
||||
// userManager.bindInstallationForRegister(bu.getUsername());
|
||||
// 启动主页
|
||||
// Log.i("test","enter mainActivity");
|
||||
Intent intent = new Intent(RegisterActivity.this,MainActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onFailure(int arg0, String arg1) {
|
||||
// TODO Auto-generated method stub
|
||||
Snackbar.make(registerBtn,"注册失败:", Snackbar.LENGTH_LONG).show();
|
||||
progress.dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
import com.example.administrator.myapplication.utils.SystemUtils;
|
||||
import com.example.administrator.myapplication.widget.patternlock.LockPatternView;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
/**
|
||||
* Created by htq on 2016/8/12.
|
||||
*/
|
||||
public class SetLockActivity extends AppCompatActivity {
|
||||
|
||||
@BindView(R.id.tv_activity_set_lock_title)
|
||||
TextView mTitleTv;
|
||||
|
||||
@BindView(R.id.lockView)
|
||||
LockPatternView mLockPatternView;
|
||||
|
||||
@BindView(R.id.btn_password_clear)
|
||||
Button mClearBtn;
|
||||
|
||||
private String mPassword;
|
||||
private boolean isFirst = true;
|
||||
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.activity_set_lock);
|
||||
ButterKnife.bind(this);
|
||||
setTitle("应用加锁");
|
||||
|
||||
initUI();
|
||||
}
|
||||
|
||||
private void initUI()
|
||||
{
|
||||
mLockPatternView.setActivityContext(SetLockActivity.this);
|
||||
mLockPatternView.setLockListener(new LockPatternView.OnLockListener() {
|
||||
@Override
|
||||
public void getStringPassword(String password) {
|
||||
if (isFirst) {
|
||||
mPassword = password;
|
||||
mTitleTv.setText("再次输入手势密码");
|
||||
isFirst = false;
|
||||
mClearBtn.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
if (password.equals(mPassword)) {
|
||||
new SystemUtils(SetLockActivity.this).set("password",password);
|
||||
new SystemUtils(SetLockActivity.this).setBoolean("isSetLock", true);
|
||||
startActivity(new Intent(SetLockActivity.this, MainActivity.class));
|
||||
SetLockActivity.this.finish();
|
||||
}else {
|
||||
isFirst =true;
|
||||
Snackbar.make( mTitleTv,"两次密码不一致,请重新设置", Snackbar.LENGTH_LONG).show();
|
||||
mPassword = "";
|
||||
|
||||
mTitleTv.setText("设置手势密码");
|
||||
mClearBtn.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPassword() {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
mClearBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mPassword = "";
|
||||
isFirst = true;
|
||||
mClearBtn.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
}
|
||||
// private void initData()
|
||||
// {
|
||||
//
|
||||
// }
|
||||
}
|
|
@ -1,104 +0,0 @@
|
|||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
import com.example.administrator.myapplication.utils.SystemUtils;
|
||||
import com.example.administrator.myapplication.widget.ToggleButton;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
/**
|
||||
* Created by htq on 2016/8/12.
|
||||
*/
|
||||
public class SettingFragment extends Fragment {
|
||||
@BindView(R.id.tb_lock)
|
||||
ToggleButton mTbLock;
|
||||
@BindView(R.id.tb_tran)
|
||||
ToggleButton mTbTran;
|
||||
@BindView(R.id.lin)
|
||||
LinearLayout mLinL;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_setting, container,
|
||||
false);
|
||||
|
||||
ButterKnife.bind(this, view);
|
||||
initView();
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
initData();
|
||||
super.onStart();
|
||||
}
|
||||
|
||||
|
||||
private void initData() {
|
||||
|
||||
SystemUtils util=new SystemUtils(getActivity());
|
||||
boolean isSetLock =util.getBoolean("isSetLock");
|
||||
if(isSetLock)
|
||||
mTbLock.setToggleOn();
|
||||
else
|
||||
mTbLock.setToggleOff();
|
||||
|
||||
boolean isTran =util.getBoolean("isTran");
|
||||
if(isTran) {
|
||||
mTbTran.setToggleOn();
|
||||
mLinL.setAlpha(0.55f);
|
||||
}
|
||||
else {
|
||||
mTbTran.setToggleOff();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void initView()
|
||||
{
|
||||
mTbLock.setOnToggleChanged(new ToggleButton.OnToggleChanged() {
|
||||
@Override
|
||||
public void onToggle(boolean on) {
|
||||
// AppContext.setLoadImage(on);
|
||||
if(on) {
|
||||
|
||||
Intent intent = new Intent(getActivity(), SetLockActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
else
|
||||
{
|
||||
new SystemUtils(getActivity()).setBoolean("isSetLock", false);
|
||||
}
|
||||
}
|
||||
});
|
||||
mTbTran.setOnToggleChanged(new ToggleButton.OnToggleChanged() {
|
||||
@Override
|
||||
public void onToggle(boolean on) {
|
||||
// AppContext.setLoadImage(on);
|
||||
if(on) {
|
||||
|
||||
new SystemUtils(getActivity()).setBoolean("isTran", true);
|
||||
mLinL.setAlpha(0.55f);
|
||||
}
|
||||
else
|
||||
{
|
||||
new SystemUtils(getActivity()).setBoolean("isTran", false);
|
||||
mLinL.setAlpha(1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
import com.example.administrator.myapplication.utils.SystemUtils;
|
||||
import com.example.administrator.myapplication.widget.patternlock.LockPatternView;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
/**
|
||||
* Created by htq on 2016/8/12.
|
||||
*/
|
||||
public class UnLockActivity extends AppCompatActivity {
|
||||
|
||||
@BindView(R.id.lockView)
|
||||
LockPatternView mLockPatternView;
|
||||
|
||||
private String mPasswordStr;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_unlock);
|
||||
ButterKnife.bind(this);
|
||||
Toast.makeText(getApplicationContext(), "密码正确", Toast.LENGTH_SHORT).show();
|
||||
mLockPatternView.setActivityContext(UnLockActivity.this);
|
||||
mLockPatternView.setLockListener(new LockPatternView.OnLockListener() {
|
||||
String password = new SystemUtils(UnLockActivity.this).getString("password");
|
||||
|
||||
@Override
|
||||
public void getStringPassword(String password) {
|
||||
mPasswordStr = password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPassword() {
|
||||
if (mPasswordStr.equals(password)) {
|
||||
Snackbar.make(mLockPatternView, "密码正确", Snackbar.LENGTH_SHORT).show();
|
||||
Intent intent = new Intent(UnLockActivity.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
UnLockActivity.this.finish();
|
||||
return true;
|
||||
} else {
|
||||
Snackbar.make(mLockPatternView, "密码不正确", Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
|
@ -1,490 +0,0 @@
|
|||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.provider.MediaStore;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
import com.example.administrator.myapplication.entity.UpdataEvent;
|
||||
import com.example.administrator.myapplication.entity.User;
|
||||
import com.example.administrator.myapplication.utils.AccountUtils;
|
||||
import com.example.administrator.myapplication.utils.BmobConstants;
|
||||
import com.example.administrator.myapplication.utils.PhotoUtil;
|
||||
import com.example.administrator.myapplication.utils.SPUtils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import cn.bmob.v3.BmobUser;
|
||||
import cn.bmob.v3.datatype.BmobFile;
|
||||
import cn.bmob.v3.listener.UpdateListener;
|
||||
import cn.bmob.v3.listener.UploadFileListener;
|
||||
|
||||
|
||||
public class UserInfoActivity extends AppCompatActivity {
|
||||
|
||||
@BindView(R.id.mine_avatar)
|
||||
ImageView headIcon;
|
||||
@BindView(R.id.rl_nick)
|
||||
RelativeLayout rlNick;
|
||||
@BindView(R.id.rl_sex)
|
||||
RelativeLayout rlSex;
|
||||
@BindView(R.id.rl_email)
|
||||
RelativeLayout rlEmail;
|
||||
@BindView(R.id.rl_account)
|
||||
RelativeLayout rlAccount;
|
||||
@BindView(R.id.exit_btn)
|
||||
Button exitBtn;
|
||||
@BindView(R.id.img_back)
|
||||
ImageButton imgBtnBack;
|
||||
|
||||
private String userSex = "";
|
||||
private final int UPDATE_USER_DIARYPWD = 1, UPDATE_USER_EMAIL = 2, UPDATE_USER_NICKNAME = 3;
|
||||
private PopupWindow mPopupWindow;
|
||||
protected int mScreenWidth;
|
||||
protected int mScreenHeight;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
// /*set it to be full screen*/
|
||||
// getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
// WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_user_info);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
DisplayMetrics metric = new DisplayMetrics();
|
||||
getWindowManager().getDefaultDisplay().getMetrics(metric);
|
||||
mScreenWidth = metric.widthPixels;
|
||||
mScreenHeight = metric.heightPixels;
|
||||
|
||||
User.initDefaultAvatar(this,headIcon);
|
||||
//refreshAvatarFromLocal(BmobConstants.MyAvatarDir+"avatarIcon.png",headIcon);
|
||||
//userManager = BmobUserManager.getInstance(this);
|
||||
}
|
||||
|
||||
@OnClick(R.id.img_back)
|
||||
public void back() {
|
||||
finish();
|
||||
}
|
||||
|
||||
@OnClick({R.id.mine_avatar, R.id.rl_nick, R.id.rl_sex, R.id.rl_email, R.id.rl_account, R.id.exit_btn})
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.mine_avatar:
|
||||
showAvatarPop();
|
||||
break;
|
||||
case R.id.rl_nick:
|
||||
AlertDialog nickNameDialog = buildeChangeInfoDialog(UPDATE_USER_NICKNAME);
|
||||
nickNameDialog.show();
|
||||
break;
|
||||
case R.id.rl_sex:
|
||||
changeUserSex();
|
||||
break;
|
||||
case R.id.rl_email:
|
||||
AlertDialog emailDialog = buildeChangeInfoDialog(UPDATE_USER_EMAIL);
|
||||
emailDialog.show();
|
||||
break;
|
||||
case R.id.rl_account:
|
||||
// login();
|
||||
break;
|
||||
case R.id.exit_btn:
|
||||
// goToRegisterActivity();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void changeUserSex() {
|
||||
final String[] sexItems = {"男", "女"};
|
||||
|
||||
AlertDialog.Builder sexBuilder = new AlertDialog.Builder(UserInfoActivity.this)
|
||||
.setTitle("选择性别")
|
||||
.setSingleChoiceItems(sexItems, 1, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
userSex = sexItems[which];
|
||||
}
|
||||
});
|
||||
sexBuilder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
// mPresenter.upDateInfo(UserBiz.UPDATE_USER_SEX, userSex);
|
||||
}
|
||||
});
|
||||
sexBuilder.create().show();
|
||||
}
|
||||
|
||||
public AlertDialog buildeChangeInfoDialog(final int chageType) {
|
||||
View layout;
|
||||
final EditText et_pwd;
|
||||
final EditText et_change;
|
||||
ImageView icon;
|
||||
String dialogTitle = "";
|
||||
//载入,初始化自定义对话框布局
|
||||
layout = getLayoutInflater().inflate(R.layout.change_info_dialog_layout, null);
|
||||
// et_pwd = (EditText) layout.findViewById(R.id.ed_pwd_confirm);
|
||||
et_change = (EditText) layout.findViewById(R.id.ed_change_info);
|
||||
icon = (ImageView) layout.findViewById(R.id.iv_change_info_icon);
|
||||
switch (chageType) {
|
||||
case UPDATE_USER_DIARYPWD:
|
||||
dialogTitle = "修改日记密码";
|
||||
et_change.setHint("新的日记密码");
|
||||
Drawable drawable1 = getDrawableByResource(R.drawable.diary_pwd);
|
||||
icon.setImageDrawable(drawable1);
|
||||
break;
|
||||
case UPDATE_USER_EMAIL:
|
||||
dialogTitle = "修改邮箱";
|
||||
et_change.setHint("设置您的邮箱");
|
||||
Drawable drawable2 = getDrawableByResource(R.drawable.email);
|
||||
icon.setImageDrawable(drawable2);
|
||||
break;
|
||||
case UPDATE_USER_NICKNAME:
|
||||
dialogTitle = "修改昵称";
|
||||
et_change.setHint("设置您的昵称");
|
||||
Drawable drawable3 = getDrawableByResource(R.drawable.nickname);
|
||||
icon.setImageDrawable(drawable3);
|
||||
break;
|
||||
}
|
||||
|
||||
//设置对话框
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this)
|
||||
.setTitle(dialogTitle)
|
||||
.setView(layout)
|
||||
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
// String pwd = et_pwd.getText().toString();
|
||||
// if (pwd.equals(AccountUtils.getUserPwd(UserInfoActivity.this))) {
|
||||
// // upDateInfo(chageType, et_change.getText().toString());
|
||||
// } else {
|
||||
// Toast.makeText(UserInfoActivity.this, "密码不正确,重新输入", Toast.LENGTH_LONG).show();
|
||||
// }
|
||||
}
|
||||
});
|
||||
//弹出对话框
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
public Drawable getDrawableByResource(int id) {
|
||||
return getResources().getDrawable(id);
|
||||
}
|
||||
|
||||
|
||||
RelativeLayout layout_choose;
|
||||
RelativeLayout layout_photo;
|
||||
PopupWindow avatorPop;
|
||||
|
||||
public String filePath = "";
|
||||
private void showAvatarPop() {
|
||||
View view = LayoutInflater.from(this).inflate(R.layout.pop_showavator,
|
||||
null);
|
||||
layout_choose = (RelativeLayout) view.findViewById(R.id.layout_choose);
|
||||
layout_photo = (RelativeLayout) view.findViewById(R.id.layout_photo);
|
||||
layout_photo.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
layout_choose.setBackgroundColor(getResources().getColor(
|
||||
R.color.base_color_text_white));
|
||||
layout_photo.setBackgroundDrawable(getResources().getDrawable(
|
||||
R.drawable.pop_bg_press));
|
||||
File dir = new File(BmobConstants.MyAvatarDir);
|
||||
if (!dir.exists()) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
// 原图
|
||||
File file = new File(dir, new SimpleDateFormat("yyMMddHHmmss")
|
||||
.format(new Date()));
|
||||
filePath = file.getAbsolutePath();// 获取相片的保存路径
|
||||
Uri imageUri = Uri.fromFile(file);
|
||||
|
||||
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
|
||||
startActivityForResult(intent,
|
||||
BmobConstants.REQUESTCODE_UPLOADAVATAR_CAMERA);
|
||||
}
|
||||
});
|
||||
layout_choose.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
// ShowLog("点击相册");
|
||||
layout_photo.setBackgroundColor(getResources().getColor(
|
||||
R.color.base_color_text_white));
|
||||
layout_choose.setBackgroundDrawable(getResources().getDrawable(
|
||||
R.drawable.pop_bg_press));
|
||||
Intent intent = new Intent(Intent.ACTION_PICK, null);
|
||||
intent.setDataAndType(
|
||||
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
|
||||
startActivityForResult(intent,
|
||||
BmobConstants.REQUESTCODE_UPLOADAVATAR_LOCATION);
|
||||
}
|
||||
});
|
||||
|
||||
avatorPop = new PopupWindow(view, mScreenWidth, 600);
|
||||
avatorPop.setTouchInterceptor(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
|
||||
avatorPop.dismiss();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
avatorPop.setWidth(WindowManager.LayoutParams.MATCH_PARENT);
|
||||
avatorPop.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
|
||||
avatorPop.setTouchable(true);
|
||||
avatorPop.setFocusable(true);
|
||||
avatorPop.setOutsideTouchable(true);
|
||||
avatorPop.setBackgroundDrawable(new BitmapDrawable());
|
||||
// 动画效果 从底部弹起
|
||||
avatorPop.setAnimationStyle(R.style.Animations_GrowFromBottom);
|
||||
avatorPop.showAtLocation(exitBtn, Gravity.BOTTOM, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Title: startImageAction
|
||||
* @return void
|
||||
* @throws
|
||||
*/
|
||||
private void startImageAction(Uri uri, int outputX, int outputY,
|
||||
int requestCode, boolean isCrop) {
|
||||
Intent intent = null;
|
||||
if (isCrop) {
|
||||
intent = new Intent("com.android.camera.action.CROP");
|
||||
} else {
|
||||
intent = new Intent(Intent.ACTION_GET_CONTENT, null);
|
||||
}
|
||||
intent.setDataAndType(uri, "image/*");
|
||||
// intent.putExtra("output", Uri.fromFile(new File(BaseApplication.avatarPath)));
|
||||
intent.putExtra("crop", "true");
|
||||
intent.putExtra("aspectX", 1);
|
||||
intent.putExtra("aspectY", 1);
|
||||
intent.putExtra("outputX", outputX);
|
||||
intent.putExtra("outputY", outputY);
|
||||
intent.putExtra("scale", true);
|
||||
// intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);//直接输出文件
|
||||
intent.putExtra("return-data", true);
|
||||
intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
|
||||
intent.putExtra("noFaceDetection", true); // no face detection
|
||||
startActivityForResult(intent, requestCode);
|
||||
}
|
||||
|
||||
Bitmap newBitmap;
|
||||
boolean isFromCamera = false;// 区分拍照旋转
|
||||
int degree = 0;
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
// TODO Auto-generated method stub
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
switch (requestCode) {
|
||||
case BmobConstants.REQUESTCODE_UPLOADAVATAR_CAMERA:// 拍照修改头像
|
||||
if (resultCode == RESULT_OK) {
|
||||
if (!Environment.getExternalStorageState().equals(
|
||||
Environment.MEDIA_MOUNTED)) {
|
||||
Snackbar.make(exitBtn,"SD卡不可用", Snackbar.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
isFromCamera = true;
|
||||
File file = new File(filePath);
|
||||
degree = PhotoUtil.readPictureDegree(file.getAbsolutePath());
|
||||
// Log.i("life", "拍照后的角度:" + degree);
|
||||
startImageAction(Uri.fromFile(file), 200, 200,
|
||||
BmobConstants.REQUESTCODE_UPLOADAVATAR_CROP, true);
|
||||
}
|
||||
break;
|
||||
case BmobConstants.REQUESTCODE_UPLOADAVATAR_LOCATION:// 本地修改头像
|
||||
if (avatorPop != null) {
|
||||
avatorPop.dismiss();
|
||||
}
|
||||
Uri uri = null;
|
||||
if (data == null) {
|
||||
return;
|
||||
}
|
||||
if (resultCode == RESULT_OK) {
|
||||
if (!Environment.getExternalStorageState().equals(
|
||||
Environment.MEDIA_MOUNTED)) {
|
||||
Snackbar.make(exitBtn,"SD卡不可用", Snackbar.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
isFromCamera = false;
|
||||
uri = data.getData();
|
||||
startImageAction(uri, 200, 200,
|
||||
BmobConstants.REQUESTCODE_UPLOADAVATAR_CROP, true);
|
||||
} else {
|
||||
Snackbar.make(exitBtn,"照片获取失败", Snackbar.LENGTH_LONG).show();
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
case BmobConstants.REQUESTCODE_UPLOADAVATAR_CROP:// 裁剪头像返回
|
||||
// TODO sent to crop
|
||||
if (avatorPop != null) {
|
||||
avatorPop.dismiss();
|
||||
}
|
||||
if (data == null) {
|
||||
// Toast.makeText(this, , Toast.LENGTH_SHORT).show();
|
||||
Snackbar.make(exitBtn,"取消选择", Snackbar.LENGTH_LONG).show();
|
||||
return;
|
||||
} else {
|
||||
saveCropAvator(data);
|
||||
SPUtils.put(this,"isSetAvatar",true);
|
||||
|
||||
}
|
||||
|
||||
// 初始化文件路径
|
||||
filePath = "";
|
||||
// 上传头像
|
||||
uploadAvatar();
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void uploadAvatar() {
|
||||
//BmobLog.i("头像地址:" + path);
|
||||
final BmobFile bmobFile = new BmobFile(new File(path));
|
||||
bmobFile.upload(this, new UploadFileListener() {
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
// TODO Auto-generated method stub
|
||||
String url = bmobFile.getFileUrl(UserInfoActivity.this);
|
||||
updateUserAvatar(url);
|
||||
AccountUtils.saveUserHeadUrl(UserInfoActivity.this,url);
|
||||
toUpdateUserInfo(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgress(Integer arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onFailure(int arg0, String msg) {
|
||||
// TODO Auto-generated method stub
|
||||
Snackbar.make(exitBtn,"头像上传失败:" + msg+ String.valueOf(arg0), Snackbar.LENGTH_LONG).show();
|
||||
// ShowToast("头像上传失败:" + msg+String.valueOf(arg0));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateUserAvatar(final String url) {
|
||||
User u =new User();
|
||||
u.setUserHeadUrl(url);
|
||||
updateUserData(u,new UpdateListener() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
// TODO Auto-generated method stub
|
||||
Snackbar.make(exitBtn,"头像更新成功!", Snackbar.LENGTH_SHORT).show();
|
||||
//ShowToast();
|
||||
// 更新头像
|
||||
User.refreshAvatarFromServe(url,headIcon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(int code, String msg) {
|
||||
// TODO Auto-generated method stub
|
||||
Snackbar.make(exitBtn,"头像更新失败:" + msg+ String.valueOf(code), Snackbar.LENGTH_SHORT).show();
|
||||
//ShowToast();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void updateUserData(User user,UpdateListener listener){
|
||||
BmobUser current = user.getCurrentUser(UserInfoActivity.this);
|
||||
user.setObjectId(current.getObjectId());
|
||||
user.update(this, listener);
|
||||
}
|
||||
|
||||
String path;
|
||||
String avatarFile="avatarIcon.png";
|
||||
/**
|
||||
* 保存裁剪的头像
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
private void saveCropAvator(Intent data) {
|
||||
Bundle extras = data.getExtras();
|
||||
if (extras != null) {
|
||||
Bitmap bitmap = extras.getParcelable("data");
|
||||
// Log.i("life", "avatar - bitmap = " + bitmap);
|
||||
if (bitmap != null) {
|
||||
bitmap = PhotoUtil.toRoundCorner(bitmap, 10);
|
||||
if (isFromCamera && degree != 0) {
|
||||
bitmap = PhotoUtil.rotaingImageView(degree, bitmap);
|
||||
}
|
||||
headIcon.setImageBitmap(bitmap);
|
||||
|
||||
// 保存图片
|
||||
String filename = new SimpleDateFormat("yyMMddHHmmss")
|
||||
.format(new Date())+".png";
|
||||
path = BmobConstants.MyAvatarDir + avatarFile;//filename;
|
||||
|
||||
// PhotoUtil.saveBitmap(BmobConstants.MyAvatarDir, filename,
|
||||
// bitmap, true);
|
||||
PhotoUtil.saveBitmap(BmobConstants.MyAvatarDir, avatarFile,
|
||||
bitmap, true);
|
||||
// 上传头像
|
||||
if (bitmap != null && bitmap.isRecycled()) {
|
||||
bitmap.recycle();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新其他界面的头像
|
||||
*/
|
||||
public void toUpdateUserInfo(String url) {
|
||||
UpdataEvent event = new UpdataEvent();
|
||||
event.setType(UpdataEvent.UPDATE_USER_INFOS);
|
||||
// event.setString(BmobConstants.MyAvatarDir+avatarFile);
|
||||
event.setString(url);
|
||||
EventBus.getDefault().post(event);
|
||||
}
|
||||
}
|
|
@ -1,103 +0,0 @@
|
|||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
import com.example.administrator.myapplication.entity.User;
|
||||
import com.example.administrator.myapplication.utils.SPUtils;
|
||||
import com.example.administrator.myapplication.utils.SystemUtils;
|
||||
|
||||
import cn.bmob.v3.Bmob;
|
||||
import cn.bmob.v3.listener.SaveListener;
|
||||
|
||||
|
||||
/**
|
||||
* Created by htq on 2016/8/12.
|
||||
*/
|
||||
public class WelcomeActivity extends AppCompatActivity {
|
||||
private boolean isSetLock;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
/*set it to be no title*/
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
/*set it to be full screen*/
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_welcome);
|
||||
Bmob.initialize(this, "82cacaa4470ab6b8d61d3f0ce6d6201d");
|
||||
//初始化bmob
|
||||
// String libName = "bmob";
|
||||
// System.loadLibrary(libName );
|
||||
|
||||
isSetLock = new SystemUtils(WelcomeActivity.this).getBoolean("isSetLock");
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
Intent intent;
|
||||
if (isSetLock) {
|
||||
|
||||
intent = new Intent(WelcomeActivity.this, UnLockActivity.class);
|
||||
startActivity(intent);
|
||||
WelcomeActivity.this.finish();
|
||||
} else {
|
||||
autoLogin();
|
||||
//intent = new Intent(WelcomeActivity.this, LoginActivity.class);
|
||||
}
|
||||
|
||||
}
|
||||
}, 2000);
|
||||
}
|
||||
private void autoLogin()
|
||||
{
|
||||
if(SPUtils.contains(this,"user_name"))
|
||||
{
|
||||
String name=(String)SPUtils.get(this,"user_name","");
|
||||
String pwd=(String)SPUtils.get(this,"pwd","");
|
||||
User user = new User();
|
||||
user.setUsername(name);
|
||||
user.setPassword(pwd);
|
||||
user.login(this, new SaveListener() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
// Snackbar.make(loginBtn,"登录成功!",Snackbar.LENGTH_SHORT).show();
|
||||
goToHomeActivity();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(int code, String msg) {
|
||||
//Snackbar.make(loginBtn,"登录失败!",Snackbar.LENGTH_SHORT).show();
|
||||
Toast.makeText(WelcomeActivity.this,msg, Toast.LENGTH_SHORT).show();
|
||||
goToLoginActivity();//自动登陆失败,用户手动登陆
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
goToLoginActivity();
|
||||
}
|
||||
}
|
||||
private void goToHomeActivity()
|
||||
{
|
||||
Intent intent=new Intent(WelcomeActivity.this,MainActivity.class);
|
||||
startActivity(intent);
|
||||
WelcomeActivity.this.finish();
|
||||
|
||||
}
|
||||
private void goToLoginActivity()
|
||||
{
|
||||
Intent intent=new Intent(WelcomeActivity.this,LoginActivity.class);
|
||||
startActivity(intent);
|
||||
WelcomeActivity.this.finish();
|
||||
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
|
||||
public class pic_view extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_pic_view);
|
||||
}
|
||||
}
|
|
@ -1,110 +0,0 @@
|
|||
package com.example.administrator.myapplication.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.example.administrator.myapplication.entity.User;
|
||||
|
||||
|
||||
/**
|
||||
* 用户信息管理类
|
||||
*/
|
||||
public class AccountUtils {
|
||||
|
||||
private static final String USER_NAME = "user_name";
|
||||
private static final String USER_PWD = "user_pwd";
|
||||
private static final String USER_ID = "user_id";
|
||||
private static final String USER_EMAIL = "user_email";
|
||||
private static final String USER_NICK_NAME = "user_nickname";
|
||||
private static final String USER_NOTE_PWD = "user_note_pwd";
|
||||
private static final String USER_SEX = "user_sex";
|
||||
private static final String USER_HEAD_URL = "user_head_url";
|
||||
|
||||
/**
|
||||
* 保存用户的所有信息
|
||||
* @param context
|
||||
* @param user
|
||||
* @param user_pwd 用户的登录密码
|
||||
*/
|
||||
public static void saveUserInfos(Context context, User user, String user_pwd) {
|
||||
saveUserName(context, user.getUsername());
|
||||
saveUserPwd(context, user_pwd);
|
||||
saveUserId(context, user.getObjectId());
|
||||
saveUserNickName(context, user.getUserNickname());
|
||||
saveUserEmail(context, user.getEmail());
|
||||
saveUserDiaryPwd(context, user.getUserNotePwd());
|
||||
saveUserSex(context, user.getUserSex());
|
||||
saveUserHeadUrl(context, user.getUserHeadUrl());
|
||||
}
|
||||
|
||||
|
||||
public static String getUserName(Context context) {
|
||||
return (String) com.example.administrator.myapplication.utils.SPUtils.get(context, USER_NAME, "");
|
||||
}
|
||||
|
||||
public static void saveUserName(Context context, String str) {
|
||||
com.example.administrator.myapplication.utils.SPUtils.put(context, USER_NAME, str);
|
||||
}
|
||||
|
||||
public static String getUserPwd(Context context) {
|
||||
return (String) com.example.administrator.myapplication.utils.SPUtils.get(context, USER_PWD, "");
|
||||
}
|
||||
|
||||
public static void saveUserPwd(Context context, String str) {
|
||||
com.example.administrator.myapplication.utils.SPUtils.put(context, USER_PWD, str);
|
||||
}
|
||||
|
||||
public static String getUserId(Context context) {
|
||||
return (String) com.example.administrator.myapplication.utils.SPUtils.get(context, USER_ID, "");
|
||||
}
|
||||
|
||||
public static void saveUserId(Context context, String str) {
|
||||
com.example.administrator.myapplication.utils.SPUtils.put(context, USER_ID, str);
|
||||
}
|
||||
|
||||
public static String getUserEmail(Context context) {
|
||||
return (String) com.example.administrator.myapplication.utils.SPUtils.get(context, USER_EMAIL, "");
|
||||
}
|
||||
|
||||
public static void saveUserEmail(Context context, String str) {
|
||||
if (!TextUtils.isEmpty(str)) {
|
||||
com.example.administrator.myapplication.utils.SPUtils.put(context, USER_EMAIL, str);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getUserNickName(Context context) {
|
||||
return (String) com.example.administrator.myapplication.utils.SPUtils.get(context, USER_NICK_NAME, "");
|
||||
}
|
||||
|
||||
public static void saveUserNickName(Context context, String str) {
|
||||
com.example.administrator.myapplication.utils.SPUtils.put(context, USER_NICK_NAME, str);
|
||||
}
|
||||
|
||||
public static String getUserDiaryPwd(Context context) {
|
||||
return (String) com.example.administrator.myapplication.utils.SPUtils.get(context, USER_NOTE_PWD, "");
|
||||
}
|
||||
|
||||
public static void saveUserDiaryPwd(Context context, String str) {
|
||||
com.example.administrator.myapplication.utils.SPUtils.put(context, USER_NOTE_PWD, str);
|
||||
}
|
||||
|
||||
public static String getUserSex(Context context) {
|
||||
return (String) com.example.administrator.myapplication.utils.SPUtils.get(context, USER_SEX, "");
|
||||
}
|
||||
|
||||
public static void saveUserSex(Context context, String str) {
|
||||
com.example.administrator.myapplication.utils.SPUtils.put(context, USER_SEX, str);
|
||||
}
|
||||
|
||||
public static String getUserHeadUrl(Context context){
|
||||
return (String) com.example.administrator.myapplication.utils.SPUtils.get(context, USER_HEAD_URL, "");
|
||||
}
|
||||
|
||||
|
||||
public static void saveUserHeadUrl(Context context, String str) {
|
||||
com.example.administrator.myapplication.utils.SPUtils.put(context, USER_HEAD_URL, str);
|
||||
}
|
||||
public static void clearAllInfos(Context context){
|
||||
com.example.administrator.myapplication.utils.SPUtils.clear(context);
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
package com.example.administrator.myapplication.utils;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Environment;
|
||||
|
||||
|
||||
@SuppressLint("SdCardPath")
|
||||
public class BmobConstants {
|
||||
|
||||
|
||||
public static String BMOB_PICTURE_PATH = Environment.getExternalStorageDirectory() + "/bmobimdemo/image/";
|
||||
|
||||
|
||||
public static String MyAvatarDir = "/sdcard/soucang/avatar/";
|
||||
|
||||
public static final int REQUESTCODE_UPLOADAVATAR_CAMERA = 1;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD>
|
||||
public static final int REQUESTCODE_UPLOADAVATAR_LOCATION = 2;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD>
|
||||
public static final int REQUESTCODE_UPLOADAVATAR_CROP = 3;//ϵͳ<EFBFBD>ü<EFBFBD>ͷ<EFBFBD><EFBFBD>
|
||||
|
||||
public static final int REQUESTCODE_TAKE_CAMERA = 0x000001;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
public static final int REQUESTCODE_TAKE_LOCAL = 0x000002;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ
|
||||
public static final int REQUESTCODE_TAKE_LOCATION = 0x000003;//λ<EFBFBD><EFBFBD>
|
||||
public static final String EXTRA_STRING = "extra_string";
|
||||
|
||||
|
||||
public static final String ACTION_REGISTER_SUCCESS_FINISH ="register.success.finish";//ע<EFBFBD><EFBFBD>ɹ<EFBFBD>֮<EFBFBD><EFBFBD><EFBFBD>½ҳ<EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD>
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
package com.example.administrator.myapplication.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
|
||||
public class CommonUtils {
|
||||
|
||||
/** */
|
||||
public static boolean isNetworkAvailable(Context context) {
|
||||
NetworkInfo info = getNetworkInfo(context);
|
||||
if (info != null) {
|
||||
return info.isAvailable();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** WIFI */
|
||||
public static boolean isWifi(Context context) {
|
||||
NetworkInfo info = getNetworkInfo(context);
|
||||
if (info != null) {
|
||||
if (info.getType() == ConnectivityManager.TYPE_WIFI)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** */
|
||||
public static boolean isMobile(Context context) {
|
||||
NetworkInfo info = getNetworkInfo(context);
|
||||
if (info != null) {
|
||||
if (info.getType() == ConnectivityManager.TYPE_MOBILE)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static NetworkInfo getNetworkInfo(Context context) {
|
||||
|
||||
ConnectivityManager cm = (ConnectivityManager) context
|
||||
.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
return cm.getActiveNetworkInfo();
|
||||
}
|
||||
|
||||
/** */
|
||||
public static boolean checkSdCard() {
|
||||
if (android.os.Environment.getExternalStorageState().equals(
|
||||
android.os.Environment.MEDIA_MOUNTED))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
package com.example.administrator.myapplication.utils;
|
||||
|
||||
/*
|
||||
常用变量集合到一起的类
|
||||
*/
|
||||
public class Constants {
|
||||
public final static String BUNDLE_KEY_PAGE = "BUNDLE_KEY_PAGE";
|
||||
public final static String BUNDLE_KEY_ARGS = "BUNDLE_KEY_ARGS";
|
||||
public static final String ALART_CONTENT="alart_content";
|
||||
public static final String TEXT_SIZE="text_size";
|
||||
public static final int TEXT_SMALL = 0;
|
||||
public static final int TEXT_MEDIUM = 1;
|
||||
public static final int TEXT_LARGE = 2;
|
||||
public static final int TEXT_SUPER = 3;
|
||||
}
|
|
@ -1,124 +0,0 @@
|
|||
package com.example.administrator.myapplication.utils;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
|
||||
|
||||
public class DialogHelp {
|
||||
|
||||
/***
|
||||
* 对话框工具类
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static AlertDialog.Builder getDialog(Context context) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/***
|
||||
* 获取一个耗时等待对话框
|
||||
* @param context
|
||||
* @param message
|
||||
* @return
|
||||
*/
|
||||
public static ProgressDialog getWaitDialog(Context context, String message) {
|
||||
ProgressDialog waitDialog = new ProgressDialog(context);
|
||||
if (!TextUtils.isEmpty(message)) {
|
||||
waitDialog.setMessage(message);
|
||||
}
|
||||
return waitDialog;
|
||||
}
|
||||
|
||||
/***
|
||||
* 获取一个信息对话框,注意需要自己手动调用show方法显示
|
||||
* @param context
|
||||
* @param message
|
||||
* @param onClickListener
|
||||
* @return
|
||||
*/
|
||||
public static AlertDialog.Builder getMessageDialog(Context context, String message, DialogInterface.OnClickListener onClickListener) {
|
||||
AlertDialog.Builder builder = getDialog(context);
|
||||
builder.setMessage(message);
|
||||
builder.setPositiveButton("确定", onClickListener);
|
||||
return builder;
|
||||
}
|
||||
|
||||
public static AlertDialog.Builder getMessageDialog(Context context, String message) {
|
||||
return getMessageDialog(context, message, null);
|
||||
}
|
||||
|
||||
public static AlertDialog.Builder getConfirmDialog(Context context, String message, DialogInterface.OnClickListener onClickListener) {
|
||||
AlertDialog.Builder builder = getDialog(context);
|
||||
builder.setMessage(Html.fromHtml(message));
|
||||
builder.setPositiveButton("确定", onClickListener);
|
||||
builder.setNegativeButton("取消", null);
|
||||
return builder;
|
||||
}
|
||||
|
||||
public static AlertDialog.Builder getConfirmDialog(Context context, String message, DialogInterface.OnClickListener onOkClickListener, DialogInterface.OnClickListener onCancleClickListener) {
|
||||
AlertDialog.Builder builder = getDialog(context);
|
||||
builder.setMessage(message);
|
||||
builder.setPositiveButton("确定", onOkClickListener);
|
||||
builder.setNegativeButton("取消", onCancleClickListener);
|
||||
return builder;
|
||||
}
|
||||
|
||||
public static AlertDialog.Builder getConfirmDialog(Context context,
|
||||
String message,
|
||||
String okString,
|
||||
String cancleString,
|
||||
DialogInterface.OnClickListener onOkClickListener,
|
||||
DialogInterface.OnClickListener onCancleClickListener) {
|
||||
return getConfirmDialog(context, "", message, okString, cancleString, onOkClickListener, onCancleClickListener);
|
||||
}
|
||||
|
||||
public static AlertDialog.Builder getConfirmDialog(Context context,
|
||||
String title,
|
||||
String message,
|
||||
String okString,
|
||||
String cancleString,
|
||||
DialogInterface.OnClickListener onOkClickListener,
|
||||
DialogInterface.OnClickListener onCancleClickListener) {
|
||||
AlertDialog.Builder builder = getDialog(context);
|
||||
if (!TextUtils.isEmpty(title)) {
|
||||
builder.setTitle(title);
|
||||
}
|
||||
builder.setMessage(message);
|
||||
builder.setPositiveButton(okString, onOkClickListener);
|
||||
builder.setNegativeButton(cancleString, onCancleClickListener);
|
||||
return builder;
|
||||
}
|
||||
|
||||
public static AlertDialog.Builder getSelectDialog(Context context, String title, String[] arrays, DialogInterface.OnClickListener onClickListener) {
|
||||
AlertDialog.Builder builder = getDialog(context);
|
||||
builder.setItems(arrays, onClickListener);
|
||||
if (!TextUtils.isEmpty(title)) {
|
||||
builder.setTitle(title);
|
||||
}
|
||||
builder.setPositiveButton("取消", null);
|
||||
return builder;
|
||||
}
|
||||
|
||||
public static AlertDialog.Builder getSelectDialog(Context context, String[] arrays, DialogInterface.OnClickListener onClickListener) {
|
||||
return getSelectDialog(context, "", arrays, onClickListener);
|
||||
}
|
||||
|
||||
public static AlertDialog.Builder getSingleChoiceDialog(Context context, String title, String[] arrays, int selectIndex, DialogInterface.OnClickListener onClickListener) {
|
||||
AlertDialog.Builder builder = getDialog(context);
|
||||
builder.setSingleChoiceItems(arrays, selectIndex, onClickListener);
|
||||
if (!TextUtils.isEmpty(title)) {
|
||||
builder.setTitle(title);
|
||||
}
|
||||
builder.setNegativeButton("取消", null);
|
||||
return builder;
|
||||
}
|
||||
|
||||
public static AlertDialog.Builder getSingleChoiceDialog(Context context, String[] arrays, int selectIndex, DialogInterface.OnClickListener onClickListener) {
|
||||
return getSingleChoiceDialog(context, "", arrays, selectIndex, onClickListener);
|
||||
}
|
||||
}
|
|
@ -1,189 +0,0 @@
|
|||
package com.example.administrator.myapplication.utils;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.animation.AlphaAnimation;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationSet;
|
||||
import android.view.animation.AnticipateInterpolator;
|
||||
import android.view.animation.OvershootInterpolator;
|
||||
import android.view.animation.RotateAnimation;
|
||||
import android.view.animation.ScaleAnimation;
|
||||
import android.view.animation.TranslateAnimation;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
/**
|
||||
* 录音动画类
|
||||
*/
|
||||
public class HTQAnimations {
|
||||
|
||||
/**
|
||||
* 旋转 Rotate
|
||||
*/
|
||||
public static Animation getRotateAnimation(float fromDegrees,
|
||||
float toDegrees, long durationMillis) {
|
||||
RotateAnimation rotate = new RotateAnimation(fromDegrees, toDegrees,
|
||||
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
|
||||
0.5f);
|
||||
rotate.setDuration(durationMillis);
|
||||
rotate.setFillAfter(true);
|
||||
return rotate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 透明度 Alpha
|
||||
*/
|
||||
public static Animation getAlphaAnimation(float fromAlpha, float toAlpha,
|
||||
long durationMillis) {
|
||||
AlphaAnimation alpha = new AlphaAnimation(fromAlpha, toAlpha);
|
||||
alpha.setDuration(durationMillis);
|
||||
alpha.setFillAfter(true);
|
||||
return alpha;
|
||||
}
|
||||
|
||||
/**
|
||||
* 缩放 Scale
|
||||
*/
|
||||
public static Animation getScaleAnimation(float scaleXY, long durationMillis) {
|
||||
ScaleAnimation scale = new ScaleAnimation(1.0f, scaleXY, 1.0f, scaleXY,
|
||||
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
|
||||
0.5f);
|
||||
scale.setDuration(durationMillis);
|
||||
return scale;
|
||||
}
|
||||
|
||||
/**
|
||||
* 位移 Translate
|
||||
*/
|
||||
public static Animation getTranslateAnimation(float fromXDelta,
|
||||
float toXDelta, float fromYDelta, float toYDelta,
|
||||
long durationMillis) {
|
||||
TranslateAnimation translate = new TranslateAnimation(fromXDelta,
|
||||
toXDelta, fromYDelta, toYDelta);
|
||||
translate.setDuration(durationMillis);
|
||||
translate.setFillAfter(true);
|
||||
return translate;
|
||||
}
|
||||
|
||||
public static Animation clickAnimation(float scaleXY, long durationMillis) {
|
||||
AnimationSet set = new AnimationSet(true);
|
||||
set.addAnimation(getScaleAnimation(scaleXY, durationMillis));
|
||||
set.setDuration(durationMillis);
|
||||
return set;
|
||||
}
|
||||
|
||||
public static Animation shakeAnimation(int X) {
|
||||
AnimationSet set = new AnimationSet(true);
|
||||
Animation anim1 = getTranslateAnimation(0, -200, 0, 0, 100);
|
||||
anim1.setStartOffset(100);
|
||||
set.addAnimation(anim1);
|
||||
Animation anim2 = getTranslateAnimation(-200, 400, 0, 0, 200);
|
||||
anim2.setStartOffset(300);
|
||||
set.addAnimation(anim2);
|
||||
Animation anim3 = getTranslateAnimation(400, -200, 0, 0, 200);
|
||||
anim3.setStartOffset(500);
|
||||
set.addAnimation(anim3);
|
||||
Animation anim4 = getTranslateAnimation(-200, 0, 0, 0, 100);
|
||||
anim4.setStartOffset(600);
|
||||
set.addAnimation(anim4);
|
||||
set.setFillAfter(true);
|
||||
set.setDuration(640);
|
||||
return set;
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开的动画
|
||||
*
|
||||
* @param relativeLayout
|
||||
* 子菜单容器
|
||||
* @param background
|
||||
* 子菜单背景
|
||||
* @param menu
|
||||
* 菜单按钮
|
||||
* @param durationMillis
|
||||
* 动画时间
|
||||
*/
|
||||
public static void openAnimation(RelativeLayout relativeLayout,
|
||||
ImageView menu, long durationMillis) {
|
||||
relativeLayout.setVisibility(View.VISIBLE);
|
||||
for (int i = 1; i < relativeLayout.getChildCount(); i++) {
|
||||
ImageView imageView = null;
|
||||
if (relativeLayout.getChildAt(i) instanceof ImageView) {
|
||||
imageView = (ImageView) relativeLayout.getChildAt(i);
|
||||
} else {
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
int top = imageView.getTop();
|
||||
int left = imageView.getLeft();
|
||||
if (top == 0) {
|
||||
top = (menu.getHeight() + 50) * i;
|
||||
}
|
||||
if (left == 0) {
|
||||
left = menu.getLeft();
|
||||
}
|
||||
AnimationSet set = new AnimationSet(true);
|
||||
set.addAnimation(getRotateAnimation(-360, 0, durationMillis));
|
||||
set.addAnimation(getAlphaAnimation(0.5f, 1.0f, durationMillis));
|
||||
set.addAnimation(getTranslateAnimation(menu.getLeft() - left, 0,
|
||||
menu.getTop() - top + 30, 0, durationMillis));// 加30是由于图片上部有一些透明高度
|
||||
set.setFillAfter(true);
|
||||
set.setDuration(durationMillis);
|
||||
set.setStartOffset((i * 100)
|
||||
/ (-1 + relativeLayout.getChildCount()));
|
||||
set.setInterpolator(new OvershootInterpolator(1f));
|
||||
imageView.startAnimation(set);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭的动画
|
||||
*
|
||||
* @param relativeLayout
|
||||
* 子菜单容器
|
||||
* @param background
|
||||
* 子菜单背景
|
||||
* @param menu
|
||||
* 菜单按钮
|
||||
* @param durationMillis
|
||||
* 动画时间
|
||||
*/
|
||||
public static void closeAnimation(final RelativeLayout relativeLayout,
|
||||
final ImageView menu, long durationMillis) {
|
||||
for (int i = 1; i < relativeLayout.getChildCount(); i++) {
|
||||
ImageView imageView = null;
|
||||
if (relativeLayout.getChildAt(i) instanceof ImageView) {
|
||||
imageView = (ImageView) relativeLayout.getChildAt(i);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
AnimationSet set = new AnimationSet(true);
|
||||
set.addAnimation(getRotateAnimation(0, -360, durationMillis));
|
||||
set.addAnimation(getAlphaAnimation(1.0f, 0.5f, durationMillis));
|
||||
set.addAnimation(getTranslateAnimation(0, menu.getLeft()
|
||||
- imageView.getLeft(), 0,
|
||||
menu.getTop() - imageView.getTop() + 30, durationMillis));// 加30是由于图片上部有一些透明高度
|
||||
set.setFillAfter(true);
|
||||
set.setDuration(durationMillis);
|
||||
set.setStartOffset(((relativeLayout.getChildCount() - i) * 100)
|
||||
/ (-1 + relativeLayout.getChildCount()));
|
||||
set.setInterpolator(new AnticipateInterpolator(1f));
|
||||
set.setAnimationListener(new Animation.AnimationListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animation arg0) {}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation arg0) {}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation arg0) {
|
||||
relativeLayout.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
imageView.startAnimation(set);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package com.example.administrator.myapplication.utils;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
||||
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
|
||||
import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;
|
||||
/*
|
||||
图片加载工具类
|
||||
*/
|
||||
public class ImageLoadOptions {
|
||||
|
||||
public static DisplayImageOptions getOptions() {
|
||||
DisplayImageOptions options = new DisplayImageOptions.Builder()
|
||||
// // <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>ͼƬ
|
||||
// .showImageOnLoading(R.drawable.small_image_holder_listpage)
|
||||
// // <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬUriΪ<EFBFBD>ջ<EFBFBD><EFBFBD>Ǵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>ͼƬ
|
||||
// .showImageForEmptyUri(R.drawable.small_image_holder_listpage)
|
||||
// // <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>ͼƬ
|
||||
// .showImageOnFail(R.drawable.small_image_holder_listpage)
|
||||
.cacheInMemory(true)
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>ͼƬ<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>
|
||||
.cacheOnDisc(true)
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>ͼƬ<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD>SD<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
.considerExifParams(true)
|
||||
.imageScaleType(ImageScaleType.EXACTLY)// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>εı<EFBFBD><EFBFBD>뷽ʽ<EFBFBD><EFBFBD>ʾ
|
||||
.bitmapConfig(Bitmap.Config.RGB_565)// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ<EFBFBD>Ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// .decodingOptions(android.graphics.BitmapFactory.Options
|
||||
// decodingOptions)//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ<EFBFBD>Ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
.considerExifParams(true)
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD>
|
||||
// .delayBeforeLoading(int delayInMillis)//int
|
||||
// delayInMillisΪ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD>ӳ<EFBFBD>ʱ<EFBFBD><EFBFBD>
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ<EFBFBD><EFBFBD><EFBFBD>뻺<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>bitmap<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <EFBFBD><EFBFBD>preProcessor(BitmapProcessor preProcessor)
|
||||
.resetViewBeforeLoading(true)// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD>λ
|
||||
// .displayer(new RoundedBitmapDisplayer(20))//<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪԲ<EFBFBD>ǣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
.displayer(new FadeInBitmapDisplayer(100))// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
.build();
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
package com.example.administrator.myapplication.utils;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
|
||||
/*
|
||||
加密工具类
|
||||
*/
|
||||
public class MD5Util {
|
||||
public static String MD5(String str) {
|
||||
MessageDigest md5 = null;
|
||||
try {
|
||||
md5 = MessageDigest.getInstance("MD5");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
|
||||
char[] charArray = str.toCharArray();
|
||||
byte[] byteArray = new byte[charArray.length];
|
||||
|
||||
for (int i = 0; i < charArray.length; i++) {
|
||||
byteArray[i] = (byte) charArray[i];
|
||||
}
|
||||
byte[] md5Bytes = md5.digest(byteArray);
|
||||
|
||||
StringBuffer hexValue = new StringBuffer();
|
||||
for (int i = 0; i < md5Bytes.length; i++) {
|
||||
int val = ((int) md5Bytes[i]) & 0xff;
|
||||
if (val < 16) {
|
||||
hexValue.append("0");
|
||||
}
|
||||
hexValue.append(Integer.toHexString(val));
|
||||
}
|
||||
return hexValue.toString();
|
||||
}
|
||||
|
||||
// 可逆的加密算法
|
||||
public static String encryptmd5(String str) {
|
||||
char[] a = str.toCharArray();
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
a[i] = (char) (a[i] ^ 'l');
|
||||
}
|
||||
String s = new String(a);
|
||||
return s;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,293 +0,0 @@
|
|||
package com.example.administrator.myapplication.utils;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Bitmap.Config;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff.Mode;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.media.ExifInterface;
|
||||
import android.media.ThumbnailUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class PhotoUtil {
|
||||
|
||||
/**
|
||||
* recycle
|
||||
* 图片选择框架
|
||||
* @throws
|
||||
*/
|
||||
public static void recycle(Bitmap bitmap) {
|
||||
|
||||
if (bitmap != null && !bitmap.isRecycled()) {
|
||||
// Ϊnull
|
||||
bitmap.recycle();
|
||||
bitmap = null;
|
||||
}
|
||||
System.gc();
|
||||
}
|
||||
|
||||
/**
|
||||
* getImageThumbnail
|
||||
*
|
||||
* @return Bitmap
|
||||
* @throws
|
||||
*/
|
||||
public static Bitmap getImageThumbnail(String imagePath, int width,
|
||||
int height) {
|
||||
Bitmap bitmap = null;
|
||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
options.inJustDecodeBounds = true;
|
||||
// bitmapΪnull
|
||||
bitmap = BitmapFactory.decodeFile(imagePath, options);
|
||||
options.inJustDecodeBounds = false; // Ϊ false
|
||||
//
|
||||
int h = options.outHeight;
|
||||
int w = options.outWidth;
|
||||
int beWidth = w / width;
|
||||
int beHeight = h / height;
|
||||
int be = 1;
|
||||
if (beWidth < beHeight) {
|
||||
be = beWidth;
|
||||
} else {
|
||||
be = beHeight;
|
||||
}
|
||||
if (be <= 0) {
|
||||
be = 1;
|
||||
}
|
||||
options.inSampleSize = be;
|
||||
// <EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD><EFBFBD><EFBFBD>ͼƬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD><EFBFBD>bitmap<EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>options.inJustDecodeBounds <EFBFBD><EFBFBD>Ϊ false
|
||||
bitmap = BitmapFactory.decodeFile(imagePath, options);
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ThumbnailUtils<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD>Bitmap<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
bitmap = ThumbnailUtils.extractThumbnail(bitmap, width, height,
|
||||
ThumbnailUtils.OPTIONS_RECYCLE_INPUT);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
/**
|
||||
* saveBitmap
|
||||
*
|
||||
* @param @param filename---<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ-<EFBFBD><EFBFBD>Ŀ¼<EFBFBD>Լ<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
|
||||
* @param @param bitmap
|
||||
* @param @param isDelete --<EFBFBD>Ƿ<EFBFBD>ֻ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>
|
||||
* @return void
|
||||
* @throws
|
||||
*/
|
||||
public static void saveBitmap(String dirpath, String filename,
|
||||
Bitmap bitmap, boolean isDelete) {
|
||||
File dir = new File(dirpath);
|
||||
if (!dir.exists()) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
|
||||
File file = new File(dirpath, filename);
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>ɾ<EFBFBD><EFBFBD>-Ĭ<EFBFBD><EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>
|
||||
if (isDelete) {
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
file.createNewFile();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
FileOutputStream out = null;
|
||||
try {
|
||||
out = new FileOutputStream(file);
|
||||
if (bitmap.compress(Bitmap.CompressFormat.PNG, 100, out)) {
|
||||
out.flush();
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (out != null) {
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static File getFilePath(String filePath, String fileName) {
|
||||
File file = null;
|
||||
makeRootDirectory(filePath);
|
||||
try {
|
||||
file = new File(filePath + fileName);
|
||||
if (!file.exists()) {
|
||||
file.createNewFile();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
public static void makeRootDirectory(String filePath) {
|
||||
File file = null;
|
||||
try {
|
||||
file = new File(filePath);
|
||||
if (!file.exists()) {
|
||||
file.mkdirs();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* <EFBFBD><EFBFBD>ȡͼƬ<EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>ĽǶ<EFBFBD>
|
||||
* @param path ͼƬ<EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD>
|
||||
* @return degree<EFBFBD><EFBFBD>ת<EFBFBD>ĽǶ<EFBFBD>
|
||||
*/
|
||||
|
||||
public static int readPictureDegree(String path) {
|
||||
int degree = 0;
|
||||
try {
|
||||
ExifInterface exifInterface = new ExifInterface(path);
|
||||
int orientation = exifInterface.getAttributeInt(
|
||||
ExifInterface.TAG_ORIENTATION,
|
||||
ExifInterface.ORIENTATION_NORMAL);
|
||||
switch (orientation) {
|
||||
case ExifInterface.ORIENTATION_ROTATE_90:
|
||||
degree = 90;
|
||||
break;
|
||||
case ExifInterface.ORIENTATION_ROTATE_180:
|
||||
degree = 180;
|
||||
break;
|
||||
case ExifInterface.ORIENTATION_ROTATE_270:
|
||||
degree = 270;
|
||||
break;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return degree;
|
||||
|
||||
}
|
||||
|
||||
/** <EFBFBD><EFBFBD>תͼƬһ<EFBFBD><EFBFBD><EFBFBD>Ƕ<EFBFBD>
|
||||
* rotaingImageView
|
||||
* @return Bitmap
|
||||
* @throws
|
||||
*/
|
||||
public static Bitmap rotaingImageView(int angle, Bitmap bitmap) {
|
||||
|
||||
Matrix matrix = new Matrix();
|
||||
matrix.postRotate(angle);
|
||||
|
||||
Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0,
|
||||
bitmap.getWidth(), bitmap.getHeight(), matrix, true);
|
||||
return resizedBitmap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static Bitmap toRoundCorner(Bitmap bitmap, int pixels) {
|
||||
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
|
||||
bitmap.getHeight(), Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(output);
|
||||
|
||||
final int color = 0xff424242;
|
||||
final Paint paint = new Paint();
|
||||
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
|
||||
final RectF rectF = new RectF(rect);
|
||||
final float roundPx = pixels;
|
||||
|
||||
paint.setAntiAlias(true);
|
||||
canvas.drawARGB(0, 0, 0, 0);
|
||||
paint.setColor(color);
|
||||
canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
|
||||
|
||||
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
|
||||
canvas.drawBitmap(bitmap, rect, rect, paint);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* <EFBFBD><EFBFBD>ͼƬת<EFBFBD><EFBFBD>ΪԲ<EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD>
|
||||
*
|
||||
* @Title: toRoundBitmap
|
||||
* @throws
|
||||
*/
|
||||
public static Bitmap toRoundBitmap(Bitmap bitmap) {
|
||||
int width = bitmap.getWidth();
|
||||
int height = bitmap.getHeight();
|
||||
float roundPx;
|
||||
float left, top, right, bottom, dst_left, dst_top, dst_right, dst_bottom;
|
||||
if (width <= height) {
|
||||
roundPx = width / 2;
|
||||
|
||||
left = 0;
|
||||
top = 0;
|
||||
right = width;
|
||||
bottom = width;
|
||||
|
||||
height = width;
|
||||
|
||||
dst_left = 0;
|
||||
dst_top = 0;
|
||||
dst_right = width;
|
||||
dst_bottom = width;
|
||||
} else {
|
||||
roundPx = height / 2;
|
||||
|
||||
float clip = (width - height) / 2;
|
||||
|
||||
left = clip;
|
||||
right = width - clip;
|
||||
top = 0;
|
||||
bottom = height;
|
||||
width = height;
|
||||
|
||||
dst_left = 0;
|
||||
dst_top = 0;
|
||||
dst_right = height;
|
||||
dst_bottom = height;
|
||||
}
|
||||
|
||||
Bitmap output = Bitmap.createBitmap(width, height, Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(output);
|
||||
|
||||
final Paint paint = new Paint();
|
||||
final Rect src = new Rect((int) left, (int) top, (int) right,
|
||||
(int) bottom);
|
||||
final Rect dst = new Rect((int) dst_left, (int) dst_top,
|
||||
(int) dst_right, (int) dst_bottom);
|
||||
final RectF rectF = new RectF(dst);
|
||||
|
||||
paint.setAntiAlias(true);// <EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
canvas.drawARGB(0, 0, 0, 0); // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Canvas
|
||||
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Բ,drawRounRect<EFBFBD><EFBFBD>drawCircle
|
||||
canvas.drawRoundRect(rectF, roundPx, roundPx, paint);// <EFBFBD><EFBFBD>Բ<EFBFBD>Ǿ<EFBFBD><EFBFBD>Σ<EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊͼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD>ˮƽԲ<EFBFBD>ǰ뾶<EFBFBD>ʹ<EFBFBD>ֱԲ<EFBFBD>ǰ뾶<EFBFBD><EFBFBD>
|
||||
// canvas.drawCircle(roundPx, roundPx, roundPx, paint);
|
||||
|
||||
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ<EFBFBD>ཻʱ<EFBFBD><EFBFBD>ģʽ,<EFBFBD>ο<EFBFBD>http://trylovecatch.iteye.com/blog/1189452
|
||||
canvas.drawBitmap(bitmap, src, dst, paint); // <EFBFBD><EFBFBD>Mode.SRC_INģʽ<EFBFBD>ϲ<EFBFBD>bitmap<EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD>draw<EFBFBD>˵<EFBFBD>Circle
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package com.example.administrator.myapplication.utils;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
|
||||
/**
|
||||
* 资源处理工具类
|
||||
*/
|
||||
public class ResourceParser {
|
||||
public static final int TEXT_SMALL = 0;
|
||||
public static final int TEXT_MEDIUM = 1;
|
||||
public static final int TEXT_LARGE = 2;
|
||||
public static final int TEXT_SUPER = 3;
|
||||
|
||||
public static final int BG_DEFAULT_FONT_SIZE = TEXT_MEDIUM;
|
||||
|
||||
public static class TextAppearanceResources {
|
||||
private final static int [] TEXTAPPEARANCE_RESOURCES = new int [] {
|
||||
R.style.TextAppearanceNormal,
|
||||
R.style.TextAppearanceMedium,
|
||||
R.style.TextAppearanceLarge,
|
||||
R.style.TextAppearanceSuper
|
||||
};
|
||||
|
||||
public static int getTexAppearanceResource(int id) {
|
||||
/**
|
||||
* HACKME: Fix bug of store the resource id in shared preference.
|
||||
* The id may larger than the length of resources, in this case,
|
||||
* return the {@link ResourceParser#BG_DEFAULT_FONT_SIZE}
|
||||
*/
|
||||
if (id >= TEXTAPPEARANCE_RESOURCES.length) {
|
||||
return BG_DEFAULT_FONT_SIZE;
|
||||
}
|
||||
return TEXTAPPEARANCE_RESOURCES[id];
|
||||
}
|
||||
|
||||
public static int getResourcesSize() {
|
||||
return TEXTAPPEARANCE_RESOURCES.length;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,195 +0,0 @@
|
|||
package com.example.administrator.myapplication.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by Wentong WANG on 2016/6/6.
|
||||
*/
|
||||
public class SPUtils {
|
||||
/**
|
||||
* 保存在手机里面的文件名
|
||||
*/
|
||||
public static final String FILE_NAME = "user_data";
|
||||
|
||||
/**
|
||||
* 保存数据的方法,我们需要拿到保存数据的具体类型,然后根据类型调用不同的保存方法
|
||||
*
|
||||
* @param context
|
||||
* @param key
|
||||
* @param object
|
||||
*/
|
||||
public static void put(Context context, String key, Object object)
|
||||
{
|
||||
|
||||
SharedPreferences sp = context.getSharedPreferences(FILE_NAME,
|
||||
Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
|
||||
if (object instanceof String)
|
||||
{
|
||||
editor.putString(key, (String) object);
|
||||
} else if (object instanceof Integer)
|
||||
{
|
||||
editor.putInt(key, (Integer) object);
|
||||
} else if (object instanceof Boolean)
|
||||
{
|
||||
editor.putBoolean(key, (Boolean) object);
|
||||
} else if (object instanceof Float)
|
||||
{
|
||||
editor.putFloat(key, (Float) object);
|
||||
} else if (object instanceof Long)
|
||||
{
|
||||
editor.putLong(key, (Long) object);
|
||||
} else
|
||||
{
|
||||
editor.putString(key, object.toString());
|
||||
}
|
||||
|
||||
SharedPreferencesCompat.apply(editor);
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到保存数据的方法,我们根据默认值得到保存的数据的具体类型,然后调用相对于的方法获取值
|
||||
*
|
||||
* @param context
|
||||
* @param key
|
||||
* @param defaultObject
|
||||
* @return
|
||||
*/
|
||||
public static Object get(Context context, String key, Object defaultObject)
|
||||
{
|
||||
SharedPreferences sp = context.getSharedPreferences(FILE_NAME,
|
||||
Context.MODE_PRIVATE);
|
||||
|
||||
if (defaultObject instanceof String)
|
||||
{
|
||||
return sp.getString(key, (String) defaultObject);
|
||||
} else if (defaultObject instanceof Integer)
|
||||
{
|
||||
return sp.getInt(key, (Integer) defaultObject);
|
||||
} else if (defaultObject instanceof Boolean)
|
||||
{
|
||||
return sp.getBoolean(key, (Boolean) defaultObject);
|
||||
} else if (defaultObject instanceof Float)
|
||||
{
|
||||
return sp.getFloat(key, (Float) defaultObject);
|
||||
} else if (defaultObject instanceof Long)
|
||||
{
|
||||
return sp.getLong(key, (Long) defaultObject);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除某个key值已经对应的值
|
||||
* @param context
|
||||
* @param key
|
||||
*/
|
||||
public static void remove(Context context, String key)
|
||||
{
|
||||
SharedPreferences sp = context.getSharedPreferences(FILE_NAME,
|
||||
Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
editor.remove(key);
|
||||
SharedPreferencesCompat.apply(editor);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除所有数据
|
||||
* @param context
|
||||
*/
|
||||
public static void clear(Context context)
|
||||
{
|
||||
SharedPreferences sp = context.getSharedPreferences(FILE_NAME,
|
||||
Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
editor.clear();
|
||||
SharedPreferencesCompat.apply(editor);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询某个key是否已经存在
|
||||
* @param context
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public static boolean contains(Context context, String key)
|
||||
{
|
||||
SharedPreferences sp = context.getSharedPreferences(FILE_NAME,
|
||||
Context.MODE_PRIVATE);
|
||||
return sp.contains(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回所有的键值对
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static Map<String, ?> getAll(Context context)
|
||||
{
|
||||
SharedPreferences sp = context.getSharedPreferences(FILE_NAME,
|
||||
Context.MODE_PRIVATE);
|
||||
return sp.getAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建一个解决SharedPreferencesCompat.apply方法的一个兼容类
|
||||
*
|
||||
* @author zhy
|
||||
*
|
||||
*/
|
||||
private static class SharedPreferencesCompat
|
||||
{
|
||||
private static final Method sApplyMethod = findApplyMethod();
|
||||
|
||||
/**
|
||||
* 反射查找apply的方法
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
private static Method findApplyMethod()
|
||||
{
|
||||
try
|
||||
{
|
||||
Class clz = SharedPreferences.Editor.class;
|
||||
return clz.getMethod("apply");
|
||||
} catch (NoSuchMethodException e)
|
||||
{
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果找到则使用apply执行,否则使用commit
|
||||
*
|
||||
* @param editor
|
||||
*/
|
||||
public static void apply(SharedPreferences.Editor editor)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (sApplyMethod != null)
|
||||
{
|
||||
sApplyMethod.invoke(editor);
|
||||
return;
|
||||
}
|
||||
} catch (IllegalArgumentException e)
|
||||
{
|
||||
} catch (IllegalAccessException e)
|
||||
{
|
||||
} catch (InvocationTargetException e)
|
||||
{
|
||||
}
|
||||
editor.commit();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,595 +0,0 @@
|
|||
package com.example.administrator.myapplication.utils;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 字符串操作工具包
|
||||
*
|
||||
*/
|
||||
public class StringUtils {
|
||||
private final static Pattern emailer = Pattern
|
||||
.compile("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");
|
||||
|
||||
private final static Pattern IMG_URL = Pattern
|
||||
.compile(".*?(gif|jpeg|png|jpg|bmp)");
|
||||
|
||||
private final static Pattern URL = Pattern
|
||||
.compile("^(https|http)://.*?$(net|com|.com.cn|org|me|)");
|
||||
|
||||
private final static ThreadLocal<SimpleDateFormat> dateFormater = new ThreadLocal<SimpleDateFormat>() {
|
||||
@Override
|
||||
protected SimpleDateFormat initialValue() {
|
||||
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
};
|
||||
|
||||
private final static ThreadLocal<SimpleDateFormat> dateFormater2 = new ThreadLocal<SimpleDateFormat>() {
|
||||
@Override
|
||||
protected SimpleDateFormat initialValue() {
|
||||
return new SimpleDateFormat("yyyy-MM-dd");
|
||||
}
|
||||
};
|
||||
|
||||
private final static ThreadLocal<SimpleDateFormat> dateFormat3 = new ThreadLocal<SimpleDateFormat>() {
|
||||
@Override
|
||||
protected SimpleDateFormat initialValue() {
|
||||
return new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 将字符串转位日期类型
|
||||
*
|
||||
* @param sdate
|
||||
* @return
|
||||
*/
|
||||
public static Date toDate(String sdate) {
|
||||
return toDate(sdate, dateFormater.get());
|
||||
}
|
||||
|
||||
public static Date toDate(String sdate, SimpleDateFormat dateFormater) {
|
||||
try {
|
||||
return dateFormater.parse(sdate);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getDateString(Date date) {
|
||||
return dateFormater.get().format(date);
|
||||
}
|
||||
|
||||
public static String getDateString(String sdate) {
|
||||
return dateFormat3.get().format(toDate(sdate));
|
||||
}
|
||||
|
||||
/**
|
||||
* 以友好的方式显示时间
|
||||
*
|
||||
* @param sdate
|
||||
* @return
|
||||
*/
|
||||
public static String friendly_time(String sdate) {
|
||||
Date time = null;
|
||||
|
||||
if (TimeZoneUtil.isInEasternEightZones())
|
||||
time = toDate(sdate);
|
||||
else
|
||||
time = TimeZoneUtil.transformTime(toDate(sdate),
|
||||
TimeZone.getTimeZone("GMT+08"), TimeZone.getDefault());
|
||||
|
||||
if (time == null) {
|
||||
return "Unknown";
|
||||
}
|
||||
String ftime = "";
|
||||
Calendar cal = Calendar.getInstance();
|
||||
|
||||
// 判断是否是同一天
|
||||
String curDate = dateFormater2.get().format(cal.getTime());
|
||||
String paramDate = dateFormater2.get().format(time);
|
||||
if (curDate.equals(paramDate)) {
|
||||
int hour = (int) ((cal.getTimeInMillis() - time.getTime()) / 3600000);
|
||||
if (hour == 0)
|
||||
ftime = Math.max(
|
||||
(cal.getTimeInMillis() - time.getTime()) / 60000, 1)
|
||||
+ "分钟前";
|
||||
else
|
||||
ftime = hour + "小时前";
|
||||
return ftime;
|
||||
}
|
||||
|
||||
long lt = time.getTime() / 86400000;
|
||||
long ct = cal.getTimeInMillis() / 86400000;
|
||||
int days = (int) (ct - lt);
|
||||
if (days == 0) {
|
||||
int hour = (int) ((cal.getTimeInMillis() - time.getTime()) / 3600000);
|
||||
if (hour == 0)
|
||||
ftime = Math.max(
|
||||
(cal.getTimeInMillis() - time.getTime()) / 60000, 1)
|
||||
+ "分钟前";
|
||||
else
|
||||
ftime = hour + "小时前";
|
||||
} else if (days == 1) {
|
||||
ftime = "昨天";
|
||||
} else if (days == 2) {
|
||||
ftime = "前天 ";
|
||||
} else if (days > 2 && days < 31) {
|
||||
ftime = days + "天前";
|
||||
} else if (days >= 31 && days <= 2 * 31) {
|
||||
ftime = "一个月前";
|
||||
} else if (days > 2 * 31 && days <= 3 * 31) {
|
||||
ftime = "2个月前";
|
||||
} else if (days > 3 * 31 && days <= 4 * 31) {
|
||||
ftime = "3个月前";
|
||||
} else {
|
||||
ftime = dateFormater2.get().format(time);
|
||||
}
|
||||
return ftime;
|
||||
}
|
||||
|
||||
public static String friendly_time2(String sdate) {
|
||||
String res = "";
|
||||
if (isEmpty(sdate))
|
||||
return "";
|
||||
|
||||
String[] weekDays = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
|
||||
String currentData = StringUtils.getDataTime("MM-dd");
|
||||
int currentDay = toInt(currentData.substring(3));
|
||||
int currentMoth = toInt(currentData.substring(0, 2));
|
||||
|
||||
int sMoth = toInt(sdate.substring(5, 7));
|
||||
int sDay = toInt(sdate.substring(8, 10));
|
||||
int sYear = toInt(sdate.substring(0, 4));
|
||||
Date dt = new Date(sYear, sMoth - 1, sDay - 1);
|
||||
|
||||
if (sDay == currentDay && sMoth == currentMoth) {
|
||||
res = "今天 / " + weekDays[getWeekOfDate(new Date())];
|
||||
} else if (sDay == currentDay + 1 && sMoth == currentMoth) {
|
||||
res = "昨天 / " + weekDays[(getWeekOfDate(new Date()) + 6) % 7];
|
||||
} else {
|
||||
if (sMoth < 10) {
|
||||
res = "0";
|
||||
}
|
||||
res += sMoth + "/";
|
||||
if (sDay < 10) {
|
||||
res += "0";
|
||||
}
|
||||
res += sDay + " / " + weekDays[getWeekOfDate(dt)];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 智能格式化
|
||||
*/
|
||||
public static String friendly_time3(String sdate) {
|
||||
String res = "";
|
||||
if (isEmpty(sdate))
|
||||
return "";
|
||||
|
||||
Date date = StringUtils.toDate(sdate);
|
||||
if (date == null)
|
||||
return sdate;
|
||||
|
||||
SimpleDateFormat format = dateFormater2.get();
|
||||
|
||||
if (isToday(date.getTime())) {
|
||||
format.applyPattern(isMorning(date.getTime()) ? "上午 hh:mm" : "下午 hh:mm");
|
||||
res = format.format(date);
|
||||
} else if (isYesterday(date.getTime())) {
|
||||
format.applyPattern(isMorning(date.getTime()) ? "昨天 上午 hh:mm" : "昨天 下午 hh:mm");
|
||||
res = format.format(date);
|
||||
} else if (isCurrentYear(date.getTime())) {
|
||||
format.applyPattern(isMorning(date.getTime()) ? "MM-dd 上午 hh:mm" : "MM-dd 下午 hh:mm");
|
||||
res = format.format(date);
|
||||
} else {
|
||||
format.applyPattern(isMorning(date.getTime()) ? "yyyy-MM-dd 上午 hh:mm" : "yyyy-MM-dd 下午 hh:mm");
|
||||
res = format.format(date);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 判断一个时间是不是上午
|
||||
*/
|
||||
public static boolean isMorning(long when) {
|
||||
android.text.format.Time time = new android.text.format.Time();
|
||||
time.set(when);
|
||||
|
||||
int hour = time.hour;
|
||||
return (hour >= 0) && (hour < 12);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 判断一个时间是不是今天
|
||||
*/
|
||||
public static boolean isToday(long when) {
|
||||
android.text.format.Time time = new android.text.format.Time();
|
||||
time.set(when);
|
||||
|
||||
int thenYear = time.year;
|
||||
int thenMonth = time.month;
|
||||
int thenMonthDay = time.monthDay;
|
||||
|
||||
time.set(System.currentTimeMillis());
|
||||
return (thenYear == time.year)
|
||||
&& (thenMonth == time.month)
|
||||
&& (thenMonthDay == time.monthDay);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 判断一个时间是不是昨天
|
||||
*/
|
||||
public static boolean isYesterday(long when) {
|
||||
android.text.format.Time time = new android.text.format.Time();
|
||||
time.set(when);
|
||||
|
||||
int thenYear = time.year;
|
||||
int thenMonth = time.month;
|
||||
int thenMonthDay = time.monthDay;
|
||||
|
||||
time.set(System.currentTimeMillis());
|
||||
return (thenYear == time.year)
|
||||
&& (thenMonth == time.month)
|
||||
&& (time.monthDay - thenMonthDay == 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 判断一个时间是不是今年
|
||||
*/
|
||||
public static boolean isCurrentYear(long when) {
|
||||
android.text.format.Time time = new android.text.format.Time();
|
||||
time.set(when);
|
||||
|
||||
int thenYear = time.year;
|
||||
|
||||
time.set(System.currentTimeMillis());
|
||||
return (thenYear == time.year);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前日期是星期几<br>
|
||||
*
|
||||
* @param dt
|
||||
* @return 当前日期是星期几
|
||||
*/
|
||||
public static int getWeekOfDate(Date dt) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(dt);
|
||||
int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
|
||||
if (w < 0)
|
||||
w = 0;
|
||||
return w;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断给定字符串时间是否为今日
|
||||
*
|
||||
* @param sdate
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isToday(String sdate) {
|
||||
boolean b = false;
|
||||
Date time = toDate(sdate);
|
||||
Date today = new Date();
|
||||
if (time != null) {
|
||||
String nowDate = dateFormater2.get().format(today);
|
||||
String timeDate = dateFormater2.get().format(time);
|
||||
if (nowDate.equals(timeDate)) {
|
||||
b = true;
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是相同的一天
|
||||
* @param sDate1 sDate1
|
||||
* @param sDate2 sDate2
|
||||
* @return
|
||||
*/
|
||||
public static boolean isSameDay(String sDate1,String sDate2){
|
||||
if(TextUtils.isEmpty(sDate1) || TextUtils.isEmpty(sDate2)){
|
||||
return false;
|
||||
}
|
||||
boolean b = false;
|
||||
Date date1 = toDate(sDate1);
|
||||
Date date2 = toDate(sDate2);
|
||||
if(date1!= null && date2 != null){
|
||||
String d1 = dateFormater2.get().format(date1);
|
||||
String d2 = dateFormater2.get().format(date2);
|
||||
if (d1.equals(d2)) {
|
||||
b = true;
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回long类型的今天的日期
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static long getToday() {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
String curDate = dateFormater2.get().format(cal.getTime());
|
||||
curDate = curDate.replace("-", "");
|
||||
return Long.parseLong(curDate);
|
||||
}
|
||||
|
||||
public static String getCurTimeStr() {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
String curDate = dateFormater.get().format(cal.getTime());
|
||||
return curDate;
|
||||
}
|
||||
|
||||
/***
|
||||
* 计算两个时间差,返回的是的秒s
|
||||
*
|
||||
* @param dete1
|
||||
* @param date2
|
||||
* @return
|
||||
* @author 火蚁 2015-2-9 下午4:50:06
|
||||
*/
|
||||
public static long calDateDifferent(String dete1, String date2) {
|
||||
|
||||
long diff = 0;
|
||||
|
||||
Date d1 = null;
|
||||
Date d2 = null;
|
||||
|
||||
try {
|
||||
d1 = dateFormater.get().parse(dete1);
|
||||
d2 = dateFormater.get().parse(date2);
|
||||
|
||||
// 毫秒ms
|
||||
diff = d2.getTime() - d1.getTime();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return diff / 1000;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断给定字符串是否空白串。 空白串是指由空格、制表符、回车符、换行符组成的字符串 若输入字符串为null或空字符串,返回true
|
||||
*
|
||||
* @param input
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isEmpty(String input) {
|
||||
if (input == null || "".equals(input))
|
||||
return true;
|
||||
|
||||
for (int i = 0; i < input.length(); i++) {
|
||||
char c = input.charAt(i);
|
||||
if (c != ' ' && c != '\t' && c != '\r' && c != '\n') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是不是一个合法的电子邮件地址
|
||||
*
|
||||
* @param email
|
||||
* @return
|
||||
*/
|
||||
public static boolean isEmail(String email) {
|
||||
if (email == null || email.trim().length() == 0)
|
||||
return false;
|
||||
return emailer.matcher(email).matches();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断一个url是否为图片url
|
||||
*
|
||||
* @param url
|
||||
* @return
|
||||
*/
|
||||
public static boolean isImgUrl(String url) {
|
||||
if (url == null || url.trim().length() == 0)
|
||||
return false;
|
||||
return IMG_URL.matcher(url).matches();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为一个合法的url地址
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static boolean isUrl(String str) {
|
||||
if (str == null || str.trim().length() == 0)
|
||||
return false;
|
||||
return URL.matcher(str).matches();
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串转整数
|
||||
*
|
||||
* @param str
|
||||
* @param defValue
|
||||
* @return
|
||||
*/
|
||||
public static int toInt(String str, int defValue) {
|
||||
try {
|
||||
return Integer.parseInt(str);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return defValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对象转整数
|
||||
*
|
||||
* @param obj
|
||||
* @return 转换异常返回 0
|
||||
*/
|
||||
public static int toInt(Object obj) {
|
||||
if (obj == null)
|
||||
return 0;
|
||||
return toInt(obj.toString(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对象转整数
|
||||
*
|
||||
* @param obj
|
||||
* @return 转换异常返回 0
|
||||
*/
|
||||
public static long toLong(String obj) {
|
||||
try {
|
||||
return Long.parseLong(obj);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串转布尔值
|
||||
*
|
||||
* @param b
|
||||
* @return 转换异常返回 false
|
||||
*/
|
||||
public static boolean toBool(String b) {
|
||||
try {
|
||||
return Boolean.parseBoolean(b);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String getString(String s) {
|
||||
return s == null ? "" : s;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将一个InputStream流转换成字符串
|
||||
*
|
||||
* @param is
|
||||
* @return
|
||||
*/
|
||||
public static String toConvertString(InputStream is) {
|
||||
StringBuffer res = new StringBuffer();
|
||||
InputStreamReader isr = new InputStreamReader(is);
|
||||
BufferedReader read = new BufferedReader(isr);
|
||||
try {
|
||||
String line;
|
||||
line = read.readLine();
|
||||
while (line != null) {
|
||||
res.append(line + "<br>");
|
||||
line = read.readLine();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (null != isr) {
|
||||
isr.close();
|
||||
isr.close();
|
||||
}
|
||||
if (null != read) {
|
||||
read.close();
|
||||
read = null;
|
||||
}
|
||||
if (null != is) {
|
||||
is.close();
|
||||
is = null;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
return res.toString();
|
||||
}
|
||||
|
||||
/***
|
||||
* 截取字符串
|
||||
*
|
||||
* @param start 从那里开始,0算起
|
||||
* @param num 截取多少个
|
||||
* @param str 截取的字符串
|
||||
* @return
|
||||
*/
|
||||
public static String getSubString(int start, int num, String str) {
|
||||
if (str == null) {
|
||||
return "";
|
||||
}
|
||||
int leng = str.length();
|
||||
if (start < 0) {
|
||||
start = 0;
|
||||
}
|
||||
if (start > leng) {
|
||||
start = leng;
|
||||
}
|
||||
if (num < 0) {
|
||||
num = 1;
|
||||
}
|
||||
int end = start + num;
|
||||
if (end > leng) {
|
||||
end = leng;
|
||||
}
|
||||
return str.substring(start, end);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前时间为每年第几周
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static int getWeekOfYear() {
|
||||
return getWeekOfYear(new Date());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前时间为每年第几周
|
||||
*
|
||||
* @param date
|
||||
* @return
|
||||
*/
|
||||
public static int getWeekOfYear(Date date) {
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.setFirstDayOfWeek(Calendar.MONDAY);
|
||||
c.setTime(date);
|
||||
int week = c.get(Calendar.WEEK_OF_YEAR) - 1;
|
||||
week = week == 0 ? 52 : week;
|
||||
return week > 0 ? week : 1;
|
||||
}
|
||||
|
||||
public static int[] getCurrentDate() {
|
||||
int[] dateBundle = new int[3];
|
||||
String[] temp = getDataTime("yyyy-MM-dd").split("-");
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
try {
|
||||
dateBundle[i] = Integer.parseInt(temp[i]);
|
||||
} catch (Exception e) {
|
||||
dateBundle[i] = 0;
|
||||
}
|
||||
}
|
||||
return dateBundle;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回当前系统时间
|
||||
*/
|
||||
public static String getDataTime(String format) {
|
||||
SimpleDateFormat df = new SimpleDateFormat(format);
|
||||
return df.format(new Date());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,225 +0,0 @@
|
|||
package com.example.administrator.myapplication.utils;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.AssetManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.util.DisplayMetrics;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
|
||||
/**
|
||||
* 系统工具类
|
||||
*/
|
||||
public class SystemUtils {
|
||||
|
||||
private Context context;
|
||||
private String PREF_NAME = "creativelocker.pref";
|
||||
public final String KEY_NOTE_DRAFT = "KEY_NOTE_DRAFT";
|
||||
private final String BG_PIC_PATH ="bg_pic_path";
|
||||
|
||||
public SystemUtils(Context context)
|
||||
{
|
||||
this.context=context;
|
||||
}
|
||||
|
||||
public String getNoteDraft() {
|
||||
return getPreferences().getString(
|
||||
KEY_NOTE_DRAFT , "");
|
||||
}
|
||||
|
||||
|
||||
public void setNoteDraft(String draft) {
|
||||
set(KEY_NOTE_DRAFT , draft);
|
||||
}
|
||||
|
||||
public void set(String key, String value) {
|
||||
SharedPreferences.Editor editor = getPreferences().edit();
|
||||
editor.putString(key, value);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
public SharedPreferences getPreferences() {
|
||||
SharedPreferences pre =context.getSharedPreferences(PREF_NAME,
|
||||
Context.MODE_MULTI_PROCESS);
|
||||
return pre;
|
||||
}
|
||||
|
||||
public boolean isFirstUse()
|
||||
{
|
||||
if(getString("isFirstUse")==null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public boolean isTarn()
|
||||
{
|
||||
return getBoolean("isTran");
|
||||
}
|
||||
public String getString(String str)
|
||||
{
|
||||
SharedPreferences share= getPreferences();
|
||||
return share.getString(str,null);
|
||||
}
|
||||
public boolean getBoolean(String str)
|
||||
{
|
||||
SharedPreferences share= getPreferences();
|
||||
return share.getBoolean(str,false);
|
||||
}
|
||||
public void setBoolean(String str,boolean bool)
|
||||
{
|
||||
SharedPreferences.Editor editor = getPreferences().edit();
|
||||
editor.putBoolean(str,bool);
|
||||
editor.commit();
|
||||
}
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||
public SharedPreferences getPreferences(String prefName) {
|
||||
return context.getSharedPreferences(prefName,
|
||||
Context.MODE_MULTI_PROCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取屏幕宽度
|
||||
*/
|
||||
public static int getScreenW(Context aty) {
|
||||
DisplayMetrics dm = aty.getResources().getDisplayMetrics();
|
||||
return dm.widthPixels;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取屏幕高度
|
||||
*/
|
||||
public static int getScreenH(Context aty) {
|
||||
DisplayMetrics dm = aty.getResources().getDisplayMetrics();
|
||||
return dm.heightPixels;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存背景皮肤图片的地址
|
||||
*/
|
||||
public void saveBgPicPath(String path)
|
||||
{
|
||||
set(BG_PIC_PATH,path);
|
||||
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return getString(BG_PIC_PATH);
|
||||
}
|
||||
|
||||
public Bitmap getBitmapByPath(Activity aty, String path) {
|
||||
AssetManager am = aty.getAssets();
|
||||
Bitmap bitmap = null;
|
||||
InputStream is =null;
|
||||
try {
|
||||
is = am.open("bkgs/" + path);
|
||||
bitmap = BitmapFactory.decodeStream(is);
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mActivity
|
||||
* bolg:bolg.csdn.net/htq__
|
||||
*/
|
||||
public static void shareApp(Activity mActivity)
|
||||
{
|
||||
String shareAppContent="各位亲爱的小伙伴们,我发现了一款非常好用且颜值爆表的一件收藏App,分享给大家";
|
||||
|
||||
new File(mActivity.getFilesDir(), "share.jpg").deleteOnExit();
|
||||
FileOutputStream fileOutputStream=null;
|
||||
try {
|
||||
fileOutputStream = mActivity.openFileOutput(
|
||||
"share.jpg", MODE_PRIVATE);
|
||||
} catch (FileNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Bitmap pic=BitmapFactory.decodeResource(mActivity.getResources(),R.mipmap.app_icon);
|
||||
pic.compress(Bitmap.CompressFormat.JPEG, 100,fileOutputStream);
|
||||
|
||||
|
||||
Intent intent = new Intent("android.intent.action.SEND");
|
||||
intent.setType("image/*");
|
||||
intent.putExtra("sms_body", shareAppContent);
|
||||
intent.putExtra("android.intent.extra.TEXT",shareAppContent);
|
||||
intent.putExtra("android.intent.extra.STREAM",
|
||||
Uri.fromFile(new File(mActivity.getFilesDir(), "share.jpg")));
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
mActivity.startActivity(Intent.createChooser(intent,"好东西要与小伙伴们一起分享"));
|
||||
}
|
||||
|
||||
public static void shareNote(Activity mActivity,String noteContent)
|
||||
{
|
||||
|
||||
// new File(mActivity.getFilesDir(), "share.jpg").deleteOnExit();
|
||||
// FileOutputStream fileOutputStream=null;
|
||||
// try {
|
||||
// fileOutputStream = mActivity.openFileOutput(
|
||||
// "share.jpg", 1);
|
||||
// } catch (FileNotFoundException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// Bitmap pic=BitmapFactory.decodeResource(mActivity.getResources(),R.mipmap.app_icon);
|
||||
// pic.compress(Bitmap.CompressFormat.JPEG, 100,fileOutputStream);
|
||||
|
||||
|
||||
Intent intent = new Intent("android.intent.action.SEND");
|
||||
// intent.setType("image/*");
|
||||
intent.setType("text/plain");
|
||||
// intent.putExtra("sms_body", noteContent);
|
||||
intent.putExtra("android.intent.extra.TEXT",noteContent);
|
||||
// intent.putExtra("android.intent.extra.STREAM",
|
||||
// Uri.fromFile(new File(mActivity.getFilesDir(), "share.jpg")));
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
mActivity.startActivity(Intent.createChooser(intent,"好东西要与小伙伴们一起分享"));
|
||||
}
|
||||
/**
|
||||
* 分享功能
|
||||
* @param msgTitle
|
||||
* 消息标题
|
||||
* @param msgText
|
||||
* 消息内容
|
||||
* @param imgPath
|
||||
* 图片路径,不分享图片则传null
|
||||
*/
|
||||
public static void shareMsg(Activity mActivity, String msgTitle, String msgText,
|
||||
String imgPath) {
|
||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||
if (imgPath == null || imgPath.equals("")) {
|
||||
intent.setType("text/plain"); // 纯文本
|
||||
} else {
|
||||
File f = new File(imgPath);
|
||||
if (f != null && f.exists() && f.isFile()) {
|
||||
intent.setType("image/jpg");
|
||||
Uri u = Uri.fromFile(f);
|
||||
intent.putExtra(Intent.EXTRA_STREAM, u);
|
||||
}
|
||||
}
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, msgTitle);
|
||||
intent.putExtra(Intent.EXTRA_TEXT, msgText);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
mActivity.startActivity(Intent.createChooser(intent,"好东西要与小伙伴们一起分享"));
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
package com.example.administrator.myapplication.utils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
/**
|
||||
* 时区
|
||||
*/
|
||||
public class TimeZoneUtil {
|
||||
|
||||
/**
|
||||
* 判断用户的设备时区是否为东八区(中国) 2014年7月31日
|
||||
* @return
|
||||
*/
|
||||
public static boolean isInEasternEightZones() {
|
||||
boolean defaultVaule = true;
|
||||
if (TimeZone.getDefault() == TimeZone.getTimeZone("GMT+08"))
|
||||
defaultVaule = true;
|
||||
else
|
||||
defaultVaule = false;
|
||||
return defaultVaule;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据不同时区,转换时间 2014年7月31日
|
||||
* @param time
|
||||
* @return
|
||||
*/
|
||||
public static Date transformTime(Date date, TimeZone oldZone, TimeZone newZone) {
|
||||
Date finalDate = null;
|
||||
if (date != null) {
|
||||
int timeOffset = oldZone.getOffset(date.getTime())
|
||||
- newZone.getOffset(date.getTime());
|
||||
finalDate = new Date(date.getTime() - timeOffset);
|
||||
}
|
||||
return finalDate;
|
||||
}
|
||||
}
|
|
@ -1,253 +0,0 @@
|
|||
package com.example.administrator.myapplication.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapShader;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Shader;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ImageView;
|
||||
import com.example.administrator.myapplication.R;
|
||||
|
||||
|
||||
/**
|
||||
* 圆形ImageView组件
|
||||
*
|
||||
*/
|
||||
public class CircleImageView extends ImageView {
|
||||
|
||||
private static final ScaleType SCALE_TYPE = ScaleType.CENTER_CROP;
|
||||
|
||||
private static final Bitmap.Config BITMAP_CONFIG = Bitmap.Config.ARGB_8888;
|
||||
private static final int COLORDRAWABLE_DIMENSION = 1;
|
||||
|
||||
private static final int DEFAULT_BORDER_WIDTH = 0;
|
||||
private static final int DEFAULT_BORDER_COLOR = Color.BLACK;
|
||||
|
||||
private final RectF mDrawableRect = new RectF();
|
||||
private final RectF mBorderRect = new RectF();
|
||||
|
||||
private final Matrix mShaderMatrix = new Matrix();
|
||||
private final Paint mBitmapPaint = new Paint();
|
||||
private final Paint mBorderPaint = new Paint();
|
||||
|
||||
private int mBorderColor = DEFAULT_BORDER_COLOR;
|
||||
private int mBorderWidth = DEFAULT_BORDER_WIDTH;
|
||||
|
||||
private Bitmap mBitmap;
|
||||
private BitmapShader mBitmapShader;
|
||||
private int mBitmapWidth;
|
||||
private int mBitmapHeight;
|
||||
|
||||
private float mDrawableRadius;
|
||||
private float mBorderRadius;
|
||||
|
||||
private boolean mReady;
|
||||
private boolean mSetupPending;
|
||||
|
||||
//默认显示圆形
|
||||
private boolean isDisplayCircle = true;
|
||||
|
||||
public CircleImageView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public CircleImageView(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public CircleImageView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
super.setScaleType(SCALE_TYPE);
|
||||
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleImageView, defStyle, 0);
|
||||
|
||||
mBorderWidth = a.getDimensionPixelSize(R.styleable.CircleImageView_border_width, DEFAULT_BORDER_WIDTH);
|
||||
mBorderColor = a.getColor(R.styleable.CircleImageView_border_color, DEFAULT_BORDER_COLOR);
|
||||
|
||||
a.recycle();
|
||||
|
||||
mReady = true;
|
||||
|
||||
if (mSetupPending) {
|
||||
setup();
|
||||
mSetupPending = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScaleType getScaleType() {
|
||||
return SCALE_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setScaleType(ScaleType scaleType) {
|
||||
if (scaleType != SCALE_TYPE) {
|
||||
throw new IllegalArgumentException(String.format("ScaleType %s not supported.", scaleType));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
if(!isDisplayCircle) {
|
||||
super.onDraw(canvas);
|
||||
return;
|
||||
}
|
||||
if (getDrawable() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
canvas.drawCircle(getWidth() / 2, getHeight() / 2, mDrawableRadius, mBitmapPaint);
|
||||
if(mBorderWidth != 0){
|
||||
canvas.drawCircle(getWidth() / 2, getHeight() / 2, mBorderRadius, mBorderPaint);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||
super.onSizeChanged(w, h, oldw, oldh);
|
||||
setup();
|
||||
}
|
||||
|
||||
public void setDisplayCircle(boolean isDisplayCircle) {
|
||||
this.isDisplayCircle = isDisplayCircle;
|
||||
}
|
||||
|
||||
public int getBorderColor() {
|
||||
return mBorderColor;
|
||||
}
|
||||
|
||||
public void setBorderColor(int borderColor) {
|
||||
if (borderColor == mBorderColor) {
|
||||
return;
|
||||
}
|
||||
|
||||
mBorderColor = borderColor;
|
||||
mBorderPaint.setColor(mBorderColor);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public int getBorderWidth() {
|
||||
return mBorderWidth;
|
||||
}
|
||||
|
||||
public void setBorderWidth(int borderWidth) {
|
||||
if (borderWidth == mBorderWidth) {
|
||||
return;
|
||||
}
|
||||
|
||||
mBorderWidth = borderWidth;
|
||||
setup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setImageBitmap(Bitmap bm) {
|
||||
super.setImageBitmap(bm);
|
||||
mBitmap = bm;
|
||||
setup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setImageDrawable(Drawable drawable) {
|
||||
super.setImageDrawable(drawable);
|
||||
mBitmap = getBitmapFromDrawable(drawable);
|
||||
setup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setImageResource(int resId) {
|
||||
super.setImageResource(resId);
|
||||
mBitmap = getBitmapFromDrawable(getDrawable());
|
||||
setup();
|
||||
}
|
||||
|
||||
private Bitmap getBitmapFromDrawable(Drawable drawable) {
|
||||
if (drawable == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (drawable instanceof BitmapDrawable) {
|
||||
return ((BitmapDrawable) drawable).getBitmap();
|
||||
}
|
||||
|
||||
try {
|
||||
Bitmap bitmap;
|
||||
|
||||
if (drawable instanceof ColorDrawable) {
|
||||
bitmap = Bitmap.createBitmap(COLORDRAWABLE_DIMENSION, COLORDRAWABLE_DIMENSION, BITMAP_CONFIG);
|
||||
} else {
|
||||
bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), BITMAP_CONFIG);
|
||||
}
|
||||
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
||||
drawable.draw(canvas);
|
||||
return bitmap;
|
||||
} catch (OutOfMemoryError e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void setup() {
|
||||
if (!mReady) {
|
||||
mSetupPending = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (mBitmap == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
mBitmapShader = new BitmapShader(mBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
|
||||
|
||||
mBitmapPaint.setAntiAlias(true);
|
||||
mBitmapPaint.setShader(mBitmapShader);
|
||||
|
||||
mBorderPaint.setStyle(Paint.Style.STROKE);
|
||||
mBorderPaint.setAntiAlias(true);
|
||||
mBorderPaint.setColor(mBorderColor);
|
||||
mBorderPaint.setStrokeWidth(mBorderWidth);
|
||||
|
||||
mBitmapHeight = mBitmap.getHeight();
|
||||
mBitmapWidth = mBitmap.getWidth();
|
||||
|
||||
mBorderRect.set(0, 0, getWidth(), getHeight());
|
||||
mBorderRadius = Math.min((mBorderRect.height() - mBorderWidth) / 2, (mBorderRect.width() - mBorderWidth) / 2);
|
||||
|
||||
mDrawableRect.set(mBorderWidth, mBorderWidth, mBorderRect.width() - mBorderWidth, mBorderRect.height() - mBorderWidth);
|
||||
mDrawableRadius = Math.min(mDrawableRect.height() / 2, mDrawableRect.width() / 2);
|
||||
|
||||
updateShaderMatrix();
|
||||
invalidate();
|
||||
}
|
||||
|
||||
private void updateShaderMatrix() {
|
||||
float scale;
|
||||
float dx = 0;
|
||||
float dy = 0;
|
||||
|
||||
mShaderMatrix.set(null);
|
||||
|
||||
if (mBitmapWidth * mDrawableRect.height() > mDrawableRect.width() * mBitmapHeight) {
|
||||
scale = mDrawableRect.height() / (float) mBitmapHeight;
|
||||
dx = (mDrawableRect.width() - mBitmapWidth * scale) * 0.5f;
|
||||
} else {
|
||||
scale = mDrawableRect.width() / (float) mBitmapWidth;
|
||||
dy = (mDrawableRect.height() - mBitmapHeight * scale) * 0.5f;
|
||||
}
|
||||
|
||||
mShaderMatrix.setScale(scale, scale);
|
||||
mShaderMatrix.postTranslate((int) (dx + 0.5f) + mBorderWidth, (int) (dy + 0.5f) + mBorderWidth);
|
||||
|
||||
mBitmapShader.setLocalMatrix(mShaderMatrix);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,675 +0,0 @@
|
|||
package com.example.administrator.myapplication.widget;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Handler;
|
||||
import android.os.Vibrator;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.Gravity;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.ViewTreeObserver.OnPreDrawListener;
|
||||
import android.view.WindowManager;
|
||||
import android.view.animation.AccelerateDecelerateInterpolator;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.GridView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListAdapter;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 跨屏滑动
|
||||
*
|
||||
*/
|
||||
public class HTQDragGridView extends GridView {
|
||||
|
||||
private long dragResponseMS = 700; // item长按响应的时间
|
||||
private int mDragPosition;// 正在拖拽的position
|
||||
|
||||
private boolean isDrag = false; // 是否可以拖拽,用于控件内部逻辑实现
|
||||
private boolean canDrag = true; // 是否可用拖拽,主要用于外部开放设置
|
||||
private boolean mAnimationEnd = true;
|
||||
|
||||
private int mDownX;
|
||||
private int mDownY;
|
||||
private int moveX;
|
||||
private int moveY;
|
||||
|
||||
private View mStartDragItemView = null; // 刚开始拖拽的item对应的View
|
||||
private ImageView mDragImageView; // 用于拖拽时显示的幻影镜像
|
||||
private Bitmap mDragBitmap; // 幻影镜像对应的Bitmap
|
||||
private View mTrashView; // 删除item的垃圾桶图标
|
||||
|
||||
private final Vibrator mVibrator; // 震动器
|
||||
private final int mStatusHeight;// 状态栏的高度
|
||||
private final WindowManager mWindowManager;
|
||||
private WindowManager.LayoutParams mWindowLayoutParams; // item镜像的布局参数
|
||||
|
||||
private int mPoint2ItemTop; // 按下的点到所在item的上边缘的距离
|
||||
private int mPoint2ItemLeft;
|
||||
private int mOffset2Top; // DragGridView距离屏幕顶部的偏移量
|
||||
private int mOffset2Left;
|
||||
|
||||
private int mDownScrollBorder; // DragGridView自动向下滚动的边界值
|
||||
private int mUpScrollBorder; // DragGridView自动向上滚动的边界值
|
||||
|
||||
private DragGridBaseAdapter mDragAdapter;
|
||||
private int mNumColumns;
|
||||
private int mColumnWidth;
|
||||
private boolean mNumColumnsSet;
|
||||
private int mHorizontalSpacing;
|
||||
|
||||
private static final int speed = 20; // DragGridView自动滚动的速度
|
||||
private static final int MOVE_OFFSET = 25;
|
||||
private boolean moved = false;
|
||||
|
||||
public static final int HANDLE_START = 0x3587;
|
||||
public static final int HANDLE_CANCLE = 0x3588;
|
||||
public static final int HANDLE_FINISH = 0x3589;
|
||||
private static OnMoveListener moveListener; // 拖拽开始与结束监听器
|
||||
private OnDeleteListener deleteListener; // 移动到垃圾桶时的监听器
|
||||
|
||||
private final TouchRect moveRect = new TouchRect();
|
||||
private final TouchRect gridRect = new TouchRect();
|
||||
private final TouchRect trashRect = new TouchRect();
|
||||
|
||||
public HTQDragGridView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public HTQDragGridView(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public HTQDragGridView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
mVibrator = (Vibrator) context
|
||||
.getSystemService(Context.VIBRATOR_SERVICE);
|
||||
mWindowManager = (WindowManager) context
|
||||
.getSystemService(Context.WINDOW_SERVICE);
|
||||
mStatusHeight = getStatusHeight(context); // 获取状态栏的高度
|
||||
|
||||
if (!mNumColumnsSet) {
|
||||
mNumColumns = AUTO_FIT;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取状态栏的高度
|
||||
*
|
||||
*/
|
||||
private static int getStatusHeight(Context context) {
|
||||
int statusHeight = 0;
|
||||
Rect localRect = new Rect();
|
||||
|
||||
((Activity) context).getWindow().getDecorView()
|
||||
.getWindowVisibleDisplayFrame(localRect);
|
||||
statusHeight = localRect.top;
|
||||
if (0 == statusHeight) {
|
||||
Class<?> localClass;
|
||||
try {
|
||||
localClass = Class.forName("com.android.internal.R$dimen");
|
||||
Object localObject = localClass.newInstance();
|
||||
int i5 = Integer.parseInt(localClass
|
||||
.getField("status_bar_height").get(localObject)
|
||||
.toString());
|
||||
statusHeight = context.getResources().getDimensionPixelSize(i5);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return statusHeight;
|
||||
}
|
||||
|
||||
private static final Handler mHandler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(android.os.Message msg) {
|
||||
if (moveListener != null) {
|
||||
if (msg.what == HANDLE_START) {
|
||||
moveListener.startMove();
|
||||
} else if (msg.what == HANDLE_FINISH) {
|
||||
moveListener.finishMove();
|
||||
} else if (msg.what == HANDLE_CANCLE) {
|
||||
moveListener.cancleMove();
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// 用来处理是否为长按的Runnable
|
||||
|
||||
private final Runnable mLongClickRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!canDrag) {
|
||||
return;
|
||||
}
|
||||
isDrag = true; // 设置可以拖拽
|
||||
moved = true;
|
||||
mHandler.sendEmptyMessage(HANDLE_START);
|
||||
mVibrator.vibrate(50); // 震动一下
|
||||
|
||||
mStartDragItemView.setVisibility(View.INVISIBLE);// 隐藏该item
|
||||
|
||||
createDragImage(mDragBitmap, mDownX, mDownY);
|
||||
mDragBitmap = null;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 若设置为AUTO_FIT,计算有多少列
|
||||
*/
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
if (mNumColumns == AUTO_FIT) {
|
||||
int numFittedColumns = 1; // 可用列
|
||||
|
||||
if (mColumnWidth > 0) {
|
||||
int gridWidth = Math.max(MeasureSpec.getSize(widthMeasureSpec)
|
||||
- getPaddingLeft() - getPaddingRight(), 0);
|
||||
numFittedColumns = gridWidth / mColumnWidth;
|
||||
if (numFittedColumns > 0) {
|
||||
while (numFittedColumns != 1) {
|
||||
if (numFittedColumns * mColumnWidth
|
||||
+ (numFittedColumns - 1) * mHorizontalSpacing > gridWidth) {
|
||||
numFittedColumns--;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
numFittedColumns = 2;
|
||||
}
|
||||
mNumColumns = numFittedColumns;
|
||||
}
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
}
|
||||
|
||||
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
initRecord();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化坐标数据
|
||||
*/
|
||||
private void initRecord() {
|
||||
gridRect.left = this.getLeft();
|
||||
gridRect.right = this.getRight();
|
||||
gridRect.top = this.getTop();
|
||||
gridRect.bottom = this.getBottom();
|
||||
if (mTrashView != null) {
|
||||
trashRect.left = mTrashView.getLeft();
|
||||
trashRect.right = mTrashView.getRight();
|
||||
trashRect.bottom = mTrashView.getBottom();
|
||||
trashRect.top = mTrashView.getTop();
|
||||
}
|
||||
}
|
||||
|
||||
/******************** preference method ********************/
|
||||
|
||||
public void setAdapter(ListAdapter adapter) {
|
||||
super.setAdapter(adapter);
|
||||
|
||||
if (adapter instanceof DragGridBaseAdapter) {
|
||||
mDragAdapter = (DragGridBaseAdapter) adapter;
|
||||
} else {
|
||||
throw new IllegalStateException(
|
||||
"the adapter must be implements DragGridAdapter");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setNumColumns(int numColumns) {
|
||||
super.setNumColumns(numColumns);
|
||||
mNumColumnsSet = true;
|
||||
this.mNumColumns = numColumns;
|
||||
}
|
||||
|
||||
|
||||
public void setColumnWidth(int columnWidth) {
|
||||
super.setColumnWidth(columnWidth);
|
||||
mColumnWidth = columnWidth;
|
||||
}
|
||||
|
||||
|
||||
public void setHorizontalSpacing(int horizontalSpacing) {
|
||||
super.setHorizontalSpacing(horizontalSpacing);
|
||||
this.mHorizontalSpacing = horizontalSpacing;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置响应拖拽的毫秒数,默认是700毫秒
|
||||
*
|
||||
* @param dragResponseMS
|
||||
*/
|
||||
public void setDragResponseMS(long dragResponseMS) {
|
||||
this.dragResponseMS = dragResponseMS;
|
||||
}
|
||||
|
||||
public void setOnDeleteListener(OnDeleteListener l) {
|
||||
this.deleteListener = l;
|
||||
}
|
||||
|
||||
public void setTrashView(View trashView) {
|
||||
this.mTrashView = trashView;
|
||||
}
|
||||
|
||||
public void setDragEnable(boolean isDrag) {
|
||||
this.canDrag = isDrag;
|
||||
if (canDrag) {
|
||||
mHandler.removeCallbacks(mLongClickRunnable);
|
||||
}
|
||||
}
|
||||
|
||||
/******************** touch method ********************/
|
||||
|
||||
|
||||
public boolean dispatchTouchEvent(MotionEvent ev) {
|
||||
if (canDrag) {
|
||||
switch (ev.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
mDownX = (int) ev.getX();
|
||||
mDownY = (int) ev.getY();
|
||||
moveRect.left = mDownX - MOVE_OFFSET;
|
||||
moveRect.right = mDownX + MOVE_OFFSET;
|
||||
moveRect.top = mDownY - MOVE_OFFSET;
|
||||
moveRect.bottom = mDownY + MOVE_OFFSET;
|
||||
|
||||
// 根据按下的X,Y坐标获取所点击item的position
|
||||
mDragPosition = pointToPosition(mDownX, mDownY);
|
||||
|
||||
if (mDragPosition == AdapterView.INVALID_POSITION) {
|
||||
return super.dispatchTouchEvent(ev);
|
||||
}
|
||||
|
||||
// 使用Handler延迟dragResponseMS执行mLongClickRunnable
|
||||
mHandler.postDelayed(mLongClickRunnable, dragResponseMS);
|
||||
|
||||
// 根据position获取该item所对应的View
|
||||
mStartDragItemView = getChildAt(mDragPosition
|
||||
- getFirstVisiblePosition());
|
||||
|
||||
mPoint2ItemTop = mDownY - mStartDragItemView.getTop();
|
||||
mPoint2ItemLeft = mDownX - mStartDragItemView.getLeft();
|
||||
|
||||
mOffset2Top = (int) (ev.getRawY() - mDownY);
|
||||
mOffset2Left = (int) (ev.getRawX() - mDownX);
|
||||
|
||||
// 获取DragGridView自动向上滚动的偏移量,小于这个值,DragGridView向下滚动
|
||||
mDownScrollBorder = getHeight() / 5;
|
||||
// 大于这个值,DragGridView向上滚动
|
||||
mUpScrollBorder = getHeight() * 4 / 5;
|
||||
|
||||
// 开启mDragItemView绘图缓存
|
||||
mStartDragItemView.setDrawingCacheEnabled(true);
|
||||
// 获取mDragItemView在缓存中的Bitmap对象
|
||||
mDragBitmap = Bitmap.createBitmap(mStartDragItemView
|
||||
.getDrawingCache());
|
||||
// 这一步很关键,释放绘图缓存,避免出现重复的镜像
|
||||
mStartDragItemView.destroyDrawingCache();
|
||||
break;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
// 如果我们在按下的item上面移动,只要不超过item的边界我们就不移除mRunnable
|
||||
if (!isTouchInItem(moveRect, ev.getX(), ev.getY())) {
|
||||
mHandler.removeCallbacks(mLongClickRunnable);
|
||||
}
|
||||
break;
|
||||
case MotionEvent.ACTION_UP:
|
||||
mHandler.removeCallbacks(mScrollRunnable);
|
||||
mHandler.removeCallbacks(mLongClickRunnable);
|
||||
if (moved && getAdapter().getCount() > 0) {
|
||||
mHandler.sendEmptyMessage(HANDLE_FINISH);
|
||||
} else {
|
||||
mHandler.sendEmptyMessage(HANDLE_CANCLE);
|
||||
}
|
||||
moved = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return super.dispatchTouchEvent(ev);
|
||||
}
|
||||
|
||||
|
||||
public boolean onTouchEvent(MotionEvent ev) {
|
||||
if (isDrag && canDrag && mDragImageView != null) {
|
||||
switch (ev.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
initRecord();
|
||||
break;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
moveX = (int) ev.getX();
|
||||
moveY = (int) ev.getY();
|
||||
|
||||
onDragItem(moveX, moveY);// 拖动item
|
||||
|
||||
if (mTrashView != null) {
|
||||
if (inTrash(moveX, moveY)) {
|
||||
mTrashView.setScaleX(1.7f);
|
||||
mTrashView.setScaleY(1.7f);
|
||||
} else {
|
||||
mTrashView.setScaleX(1f);
|
||||
mTrashView.setScaleY(1f);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MotionEvent.ACTION_UP:
|
||||
onStopDrag();
|
||||
isDrag = false;
|
||||
if (deleteListener != null && inTrash(ev.getX(), ev.getY())) {
|
||||
deleteListener.onDelete(mDragPosition);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return super.onTouchEvent(ev);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否点击在GridView的item上面
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
* @return
|
||||
*/
|
||||
private boolean isTouchInItem(TouchRect moveRect, float x, float y) {
|
||||
// 防止手抖的处理,如果是横向在item上移动是没有影响的,
|
||||
// 但是纵向由于外层上下拉控件还是会有影响,具体解决请看NoteBookFragment类中的mSwipeRefreshLayout.setOnTouchListener方法
|
||||
if (x < moveRect.right && x > moveRect.left && y < moveRect.bottom
|
||||
&& y > moveRect.top) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建拖动的镜像
|
||||
*
|
||||
* @param bitmap
|
||||
* @param downX
|
||||
* 按下的点相对父控件的X坐标
|
||||
* @param downY
|
||||
* 按下的点相对父控件的X坐标
|
||||
*/
|
||||
private void createDragImage(Bitmap bitmap, int downX, int downY) {
|
||||
mWindowLayoutParams = new WindowManager.LayoutParams();
|
||||
mWindowLayoutParams.format = PixelFormat.TRANSLUCENT; // 图片之外的其他地方透明
|
||||
|
||||
mWindowLayoutParams.gravity = Gravity.TOP | Gravity.LEFT;
|
||||
mWindowLayoutParams.x = downX - mPoint2ItemLeft + mOffset2Left;
|
||||
mWindowLayoutParams.y = downY - mPoint2ItemTop + mOffset2Top
|
||||
- mStatusHeight;
|
||||
mWindowLayoutParams.alpha = 0.55f; // 透明度
|
||||
|
||||
|
||||
mWindowLayoutParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
|
||||
mWindowLayoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
|
||||
mWindowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
|
||||
| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
|
||||
|
||||
mDragImageView = new ImageView(getContext());
|
||||
mDragImageView.setImageBitmap(bitmap);
|
||||
mWindowManager.addView(mDragImageView, mWindowLayoutParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从界面上面移动拖动镜像
|
||||
*/
|
||||
private void removeDragImage() {
|
||||
if (mDragImageView != null) {
|
||||
mWindowManager.removeView(mDragImageView);
|
||||
mDragImageView = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 拖动item,在里面实现了item镜像的位置更新,item的相互交换以及GridView的自行滚动
|
||||
*
|
||||
* @param moveX
|
||||
* @param moveY
|
||||
*/
|
||||
private void onDragItem(int moveX, int moveY) {
|
||||
mWindowLayoutParams.x = moveX - mPoint2ItemLeft + mOffset2Left;
|
||||
mWindowLayoutParams.y = moveY - mPoint2ItemTop + mOffset2Top
|
||||
- mStatusHeight;
|
||||
mWindowManager.updateViewLayout(mDragImageView, mWindowLayoutParams); // 更新镜像的位置
|
||||
onSwapItem(moveX, moveY);
|
||||
// GridView自动滚动
|
||||
mHandler.post(mScrollRunnable);
|
||||
}
|
||||
|
||||
/**
|
||||
* 手指当前处于垃圾桶图标上
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
* @return
|
||||
*/
|
||||
private boolean inTrash(float x, float y) {
|
||||
x += gridRect.left;
|
||||
y += gridRect.top;
|
||||
if (x > trashRect.left && x < trashRect.right && y > trashRect.top
|
||||
&& y < trashRect.bottom) {
|
||||
if (mHandler != null && mScrollRunnable != null) {
|
||||
mHandler.removeCallbacks(mScrollRunnable);
|
||||
}
|
||||
if (mDragImageView != null) {
|
||||
mDragImageView.setScaleX(0.6f);
|
||||
mDragImageView.setScaleY(0.6f);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
if (mDragImageView != null) {
|
||||
mDragImageView.setScaleX(1f);
|
||||
mDragImageView.setScaleY(1f);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 当moveY的值大于向上滚动的边界值,触发GridView自动向上滚动 当moveY的值小于向下滚动的边界值,触发GridView自动向下滚动
|
||||
* 否则不进行滚动
|
||||
*/
|
||||
private final Runnable mScrollRunnable = new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
int scrollY;
|
||||
if (getFirstVisiblePosition() == 0
|
||||
|| getLastVisiblePosition() == getCount() - 1) {
|
||||
mHandler.removeCallbacks(mScrollRunnable);
|
||||
}
|
||||
|
||||
if (moveY > mUpScrollBorder) {
|
||||
scrollY = speed;
|
||||
mHandler.postDelayed(mScrollRunnable, 25);
|
||||
} else if (moveY < mDownScrollBorder) {
|
||||
scrollY = -speed;
|
||||
mHandler.postDelayed(mScrollRunnable, 25);
|
||||
} else {
|
||||
scrollY = 0;
|
||||
mHandler.removeCallbacks(mScrollRunnable);
|
||||
}
|
||||
|
||||
smoothScrollBy(scrollY, 10);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 交换item,并且控制item之间的显示与隐藏效果
|
||||
*
|
||||
* @param moveX
|
||||
* @param moveY
|
||||
*/
|
||||
private void onSwapItem(int moveX, int moveY) {
|
||||
// 获取我们手指移动到的那个item的position
|
||||
|
||||
final int tempPosition = pointToPosition(moveX, moveY);
|
||||
|
||||
// 假如tempPosition 改变了并且tempPosition不等于-1,则进行交换
|
||||
|
||||
if (tempPosition != mDragPosition
|
||||
&& tempPosition != AdapterView.INVALID_POSITION
|
||||
&& mAnimationEnd) {
|
||||
mDragAdapter.reorderItems(mDragPosition, tempPosition);
|
||||
mDragAdapter.setHideItem(tempPosition);
|
||||
|
||||
final ViewTreeObserver observer = getViewTreeObserver();
|
||||
observer.addOnPreDrawListener(new OnPreDrawListener() {
|
||||
|
||||
@Override
|
||||
public boolean onPreDraw() {
|
||||
observer.removeOnPreDrawListener(this);
|
||||
animateReorder(mDragPosition, tempPosition);
|
||||
mDragPosition = tempPosition;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建移动动画
|
||||
*
|
||||
* @param view
|
||||
* @param startX
|
||||
* @param endX
|
||||
* @param startY
|
||||
* @param endY
|
||||
* @return
|
||||
*/
|
||||
private AnimatorSet createTranslationAnimations(View view, float startX,
|
||||
float endX, float startY, float endY) {
|
||||
ObjectAnimator animX = ObjectAnimator.ofFloat(view, "translationX",
|
||||
startX, endX);
|
||||
ObjectAnimator animY = ObjectAnimator.ofFloat(view, "translationY",
|
||||
startY, endY);
|
||||
AnimatorSet animSetXY = new AnimatorSet();
|
||||
animSetXY.playTogether(animX, animY);
|
||||
return animSetXY;
|
||||
}
|
||||
|
||||
/**
|
||||
* item的交换动画效果
|
||||
*
|
||||
* @param oldPosition
|
||||
* @param newPosition
|
||||
*/
|
||||
private void animateReorder(final int oldPosition, final int newPosition) {
|
||||
boolean isForward = newPosition > oldPosition;
|
||||
List<Animator> resultList = new LinkedList<Animator>();
|
||||
if (isForward) {
|
||||
for (int pos = oldPosition; pos < newPosition; pos++) {
|
||||
View view = getChildAt(pos - getFirstVisiblePosition());
|
||||
if (view == null) {
|
||||
continue;
|
||||
}
|
||||
if ((pos + 1) % mNumColumns == 0) {
|
||||
resultList.add(createTranslationAnimations(view,
|
||||
-view.getWidth() * (mNumColumns - 1), 0,
|
||||
view.getHeight(), 0));
|
||||
} else {
|
||||
resultList.add(createTranslationAnimations(view,
|
||||
view.getWidth(), 0, 0, 0));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int pos = oldPosition; pos > newPosition; pos--) {
|
||||
View view = getChildAt(pos - getFirstVisiblePosition());
|
||||
if ((pos + mNumColumns) % mNumColumns == 0) {
|
||||
resultList.add(createTranslationAnimations(view,
|
||||
view.getWidth() * (mNumColumns - 1), 0,
|
||||
-view.getHeight(), 0));
|
||||
} else {
|
||||
resultList.add(createTranslationAnimations(view,
|
||||
-view.getWidth(), 0, 0, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AnimatorSet resultSet = new AnimatorSet();
|
||||
resultSet.playTogether(resultList);
|
||||
resultSet.setDuration(300);
|
||||
resultSet.setInterpolator(new AccelerateDecelerateInterpolator());
|
||||
resultSet.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
mAnimationEnd = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mAnimationEnd = true;
|
||||
}
|
||||
});
|
||||
resultSet.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止拖拽我们将之前隐藏的item显示出来,并将镜像移除
|
||||
*/
|
||||
private void onStopDrag() {
|
||||
View view = getChildAt(mDragPosition - getFirstVisiblePosition());
|
||||
if (view != null) {
|
||||
view.setVisibility(View.VISIBLE);
|
||||
}
|
||||
mDragAdapter.setHideItem(-1);
|
||||
removeDragImage();
|
||||
|
||||
if (mTrashView != null) {
|
||||
mTrashView.setScaleX(1f);
|
||||
mTrashView.setScaleY(1f);
|
||||
}
|
||||
}
|
||||
|
||||
public void setOnMoveListener(OnMoveListener l) {
|
||||
moveListener = l;
|
||||
}
|
||||
|
||||
public interface OnMoveListener {
|
||||
void startMove();
|
||||
|
||||
void finishMove();
|
||||
|
||||
void cancleMove();
|
||||
}
|
||||
|
||||
public interface OnDeleteListener {
|
||||
void onDelete(int position);
|
||||
}
|
||||
|
||||
public interface DragGridBaseAdapter {
|
||||
/**
|
||||
* 移动时回调
|
||||
*/
|
||||
public void reorderItems(int oldPosition, int newPosition);
|
||||
|
||||
/**
|
||||
* 隐藏时回调
|
||||
*/
|
||||
public void setHideItem(int hidePosition);
|
||||
}
|
||||
|
||||
private class TouchRect {
|
||||
int top;
|
||||
int bottom;
|
||||
int left;
|
||||
int right;
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
package com.example.administrator.myapplication.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
/**
|
||||
* 圆形ImageView组件 点击事件不会穿透
|
||||
|
||||
*/
|
||||
public class NoteItemCircleView extends CircleImageView {
|
||||
|
||||
public NoteItemCircleView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public NoteItemCircleView(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public NoteItemCircleView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
super.onTouchEvent(event);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,335 +0,0 @@
|
|||
package com.example.administrator.myapplication.widget;
|
||||
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.TypeEvaluator;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Paint.Cap;
|
||||
import android.graphics.Paint.Style;
|
||||
import android.graphics.RectF;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Property;
|
||||
import android.view.View;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
|
||||
|
||||
/**
|
||||
* 开关按钮
|
||||
*/
|
||||
public class ToggleButton extends View {
|
||||
/** */
|
||||
private float radius;
|
||||
/**
|
||||
* 开启颜色
|
||||
*/
|
||||
private int onColor = Color.parseColor("#4ebb7f");
|
||||
/**
|
||||
* 关闭颜色
|
||||
*/
|
||||
private int offBorderColor = Color.parseColor("#dadbda");
|
||||
/**
|
||||
* 灰色带颜色
|
||||
*/
|
||||
private int offColor = Color.parseColor("#ffffff");
|
||||
/**
|
||||
* 手柄颜色
|
||||
*/
|
||||
private int spotColor = Color.parseColor("#ffffff");
|
||||
/**
|
||||
* 边框颜色
|
||||
*/
|
||||
private int borderColor = offBorderColor;
|
||||
/**
|
||||
* 画笔
|
||||
*/
|
||||
private Paint paint;
|
||||
/**
|
||||
* 开关状态
|
||||
*/
|
||||
private boolean toggleOn = false;
|
||||
/**
|
||||
* 边框大小
|
||||
*/
|
||||
private int borderWidth = 2;
|
||||
/**
|
||||
* 垂直中心
|
||||
*/
|
||||
private float centerY;
|
||||
/**
|
||||
* 按钮的开始和结束位置
|
||||
*/
|
||||
private float startX, endX;
|
||||
/**
|
||||
* 手柄X位置的最小和最大值
|
||||
*/
|
||||
private float spotMinX, spotMaxX;
|
||||
/**
|
||||
* 手柄大小
|
||||
*/
|
||||
private int spotSize;
|
||||
/**
|
||||
* 手柄X位置
|
||||
*/
|
||||
private float spotX;
|
||||
/**
|
||||
* 关闭时内部灰色带高度
|
||||
*/
|
||||
private float offLineWidth;
|
||||
/** */
|
||||
private RectF rect = new RectF();
|
||||
|
||||
private OnToggleChanged listener;
|
||||
|
||||
private ToggleButton(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public ToggleButton(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
setup(attrs);
|
||||
}
|
||||
|
||||
public ToggleButton(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
setup(attrs);
|
||||
}
|
||||
|
||||
public void setup(AttributeSet attrs) {
|
||||
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
paint.setStyle(Style.FILL);
|
||||
paint.setStrokeCap(Cap.ROUND);
|
||||
|
||||
this.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
toggle();
|
||||
}
|
||||
});
|
||||
|
||||
TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.ToggleButton);
|
||||
offBorderColor = typedArray.getColor(R.styleable.ToggleButton_offBorderColor, offBorderColor);
|
||||
onColor = typedArray.getColor(R.styleable.ToggleButton_onColor, onColor);
|
||||
spotColor = typedArray.getColor(R.styleable.ToggleButton_spotColor, spotColor);
|
||||
offColor = typedArray.getColor(R.styleable.ToggleButton_offColor, offColor);
|
||||
borderWidth = typedArray.getDimensionPixelSize(R.styleable.ToggleButton_toggle_border_width, borderWidth);
|
||||
typedArray.recycle();
|
||||
}
|
||||
|
||||
public void toggle() {
|
||||
toggleOn = !toggleOn;
|
||||
animateCheckedState(toggleOn);
|
||||
if (listener != null) {
|
||||
listener.onToggle(toggleOn);
|
||||
}
|
||||
}
|
||||
|
||||
public void toggleOn() {
|
||||
setToggleOn();
|
||||
if (listener != null) {
|
||||
listener.onToggle(toggleOn);
|
||||
}
|
||||
}
|
||||
|
||||
public void toggleOff() {
|
||||
setToggleOff();
|
||||
if (listener != null) {
|
||||
listener.onToggle(toggleOn);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置显示成打开样式,不会触发toggle事件
|
||||
*/
|
||||
public void setToggleOn() {
|
||||
toggleOn = true;
|
||||
setAnimatorProperty(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置显示成关闭样式,不会触发toggle事件
|
||||
*/
|
||||
public void setToggleOff() {
|
||||
toggleOn = false;
|
||||
setAnimatorProperty(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right,
|
||||
int bottom) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
|
||||
final int width = getWidth();
|
||||
final int height = getHeight();
|
||||
radius = Math.min(width, height) * 0.5f;
|
||||
centerY = radius;
|
||||
startX = radius;
|
||||
endX = width - radius;
|
||||
spotMinX = startX + borderWidth;
|
||||
spotMaxX = endX - borderWidth;
|
||||
spotSize = height - 4 * borderWidth;
|
||||
|
||||
// update values
|
||||
setAnimatorProperty(toggleOn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
super.draw(canvas);
|
||||
rect.set(0, 0, getWidth(), getHeight());
|
||||
paint.setColor(borderColor);
|
||||
canvas.drawRoundRect(rect, radius, radius, paint);
|
||||
|
||||
if (offLineWidth > 0) {
|
||||
final float cy = offLineWidth * 0.5f;
|
||||
rect.set(spotX - cy, centerY - cy, endX + cy, centerY + cy);
|
||||
paint.setColor(offColor);
|
||||
canvas.drawRoundRect(rect, cy, cy, paint);
|
||||
}
|
||||
|
||||
rect.set(spotX - 1 - radius, centerY - radius, spotX + 1.1f + radius, centerY + radius);
|
||||
paint.setColor(borderColor);
|
||||
canvas.drawRoundRect(rect, radius, radius, paint);
|
||||
|
||||
final float spotR = spotSize * 0.5f;
|
||||
rect.set(spotX - spotR, centerY - spotR, spotX + spotR, centerY + spotR);
|
||||
paint.setColor(spotColor);
|
||||
canvas.drawRoundRect(rect, spotR, spotR, paint);
|
||||
}
|
||||
|
||||
/**
|
||||
* =============================================================================================
|
||||
* The Animate
|
||||
* =============================================================================================
|
||||
*/
|
||||
private static final Interpolator ANIMATION_INTERPOLATOR = new DecelerateInterpolator();
|
||||
private static final int ANIMATION_DURATION = 280;
|
||||
private ObjectAnimator mAnimator;
|
||||
|
||||
private void animateCheckedState(boolean newCheckedState) {
|
||||
AnimatorProperty property = new AnimatorProperty();
|
||||
if (newCheckedState) {
|
||||
property.color = onColor;
|
||||
property.offLineWidth = 10;
|
||||
property.spotX = spotMaxX;
|
||||
} else {
|
||||
property.color = offBorderColor;
|
||||
property.offLineWidth = spotSize;
|
||||
property.spotX = spotMinX;
|
||||
}
|
||||
|
||||
if (mAnimator == null) {
|
||||
mAnimator = ObjectAnimator.ofObject(this, ANIM_VALUE, new AnimatorEvaluator(mCurProperty), property);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2)
|
||||
mAnimator.setAutoCancel(true);
|
||||
mAnimator.setDuration(ANIMATION_DURATION);
|
||||
mAnimator.setInterpolator(ANIMATION_INTERPOLATOR);
|
||||
} else {
|
||||
mAnimator.cancel();
|
||||
mAnimator.setObjectValues(property);
|
||||
}
|
||||
mAnimator.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* =============================================================================================
|
||||
* The custom properties
|
||||
* =============================================================================================
|
||||
*/
|
||||
|
||||
private AnimatorProperty mCurProperty = new AnimatorProperty();
|
||||
|
||||
private void setAnimatorProperty(AnimatorProperty property) {
|
||||
this.spotX = property.spotX;
|
||||
this.borderColor = property.color;
|
||||
this.offLineWidth = property.offLineWidth;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
private void setAnimatorProperty(boolean isOn) {
|
||||
AnimatorProperty property = mCurProperty;
|
||||
if (isOn) {
|
||||
property.color = onColor;
|
||||
property.offLineWidth = 10;
|
||||
property.spotX = spotMaxX;
|
||||
} else {
|
||||
property.color = offBorderColor;
|
||||
property.offLineWidth = spotSize;
|
||||
property.spotX = spotMinX;
|
||||
}
|
||||
setAnimatorProperty(property);
|
||||
}
|
||||
|
||||
private final static class AnimatorProperty {
|
||||
private int color;
|
||||
private float offLineWidth;
|
||||
private float spotX;
|
||||
}
|
||||
|
||||
private final static class AnimatorEvaluator implements TypeEvaluator<AnimatorProperty> {
|
||||
private final AnimatorProperty mProperty;
|
||||
|
||||
public AnimatorEvaluator(AnimatorProperty property) {
|
||||
mProperty = property;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnimatorProperty evaluate(float fraction, AnimatorProperty startValue, AnimatorProperty endValue) {
|
||||
// Values
|
||||
mProperty.spotX = (int) (startValue.spotX + (endValue.spotX - startValue.spotX) * fraction);
|
||||
|
||||
mProperty.offLineWidth = (int) (startValue.offLineWidth + (endValue.offLineWidth - startValue.offLineWidth) * (1 - fraction));
|
||||
|
||||
// Color
|
||||
int startA = (startValue.color >> 24) & 0xff;
|
||||
int startR = (startValue.color >> 16) & 0xff;
|
||||
int startG = (startValue.color >> 8) & 0xff;
|
||||
int startB = startValue.color & 0xff;
|
||||
|
||||
int endA = (endValue.color >> 24) & 0xff;
|
||||
int endR = (endValue.color >> 16) & 0xff;
|
||||
int endG = (endValue.color >> 8) & 0xff;
|
||||
int endB = endValue.color & 0xff;
|
||||
|
||||
mProperty.color = (startA + (int) (fraction * (endA - startA))) << 24 |
|
||||
(startR + (int) (fraction * (endR - startR))) << 16 |
|
||||
(startG + (int) (fraction * (endG - startG))) << 8 |
|
||||
(startB + (int) (fraction * (endB - startB)));
|
||||
|
||||
return mProperty;
|
||||
}
|
||||
}
|
||||
|
||||
private final static Property<ToggleButton, AnimatorProperty> ANIM_VALUE = new Property<ToggleButton, AnimatorProperty>(AnimatorProperty.class, "animValue") {
|
||||
@Override
|
||||
public AnimatorProperty get(ToggleButton object) {
|
||||
return object.mCurProperty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(ToggleButton object, AnimatorProperty value) {
|
||||
object.setAnimatorProperty(value);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
public interface OnToggleChanged {
|
||||
/**
|
||||
* @param on
|
||||
*/
|
||||
public void onToggle(boolean on);
|
||||
}
|
||||
|
||||
|
||||
public void setOnToggleChanged(OnToggleChanged onToggleChanged) {
|
||||
listener = onToggleChanged;
|
||||
}
|
||||
}
|
|
@ -1,398 +0,0 @@
|
|||
package com.example.administrator.myapplication.widget.patternlock;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class LockPatternView extends View {
|
||||
//判断线的状态
|
||||
private boolean isLineState = true;
|
||||
//判断点是否被实例化了
|
||||
private boolean isInitPoint = false;//不能被定义为static,否则很可能导致mPoints内存泄漏
|
||||
//判断手指是否离开屏幕
|
||||
private boolean isFinish = false;
|
||||
//判断手指点击屏幕时是否选中了九宫格中的点
|
||||
private boolean isSelect = false;
|
||||
// 创建MyPoint的数组
|
||||
private Point[][] mPoints;
|
||||
// 声明屏幕的宽和高
|
||||
private int mScreenHeight;
|
||||
private int mScreenWidth;
|
||||
// 声明点线的图片的半径
|
||||
private float mPointRadius;
|
||||
// 声明线的图片的高(即是半径)
|
||||
private float mLineHeight;
|
||||
// 声明鼠标移动的x,y坐标
|
||||
private float mMoveX, mMoveY;
|
||||
// 声明屏幕上的宽和高的偏移量
|
||||
private int mScreenHeightOffSet = 0;
|
||||
private int mScreenWidthOffSet = 0;
|
||||
// 创建一个画笔
|
||||
private Paint mPaint;
|
||||
// 声明资源图片
|
||||
private Bitmap mBitmapNormal;
|
||||
private Bitmap mBitmapPressed;
|
||||
private Bitmap mBitmapError;
|
||||
private Bitmap mLinePressed;
|
||||
private Bitmap mLineError;
|
||||
// 创建一个矩阵
|
||||
private Matrix mMatrix = new Matrix();
|
||||
// 创建MyPoint的列表
|
||||
private List<Point> mPointList = new ArrayList<Point>();
|
||||
// 实例化鼠标点
|
||||
private Point mMousePoint = new Point();
|
||||
// 用获取从activity中传过来的密码字符串
|
||||
private String mPassword = "";
|
||||
|
||||
private Context mContext;
|
||||
private OnLockListener mListener;
|
||||
private Activity activity;
|
||||
|
||||
public LockPatternView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
mContext = context;
|
||||
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
mPoints = new Point[3][3];
|
||||
}
|
||||
|
||||
public LockPatternView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
mPoints = new Point[3][3];
|
||||
}
|
||||
|
||||
public LockPatternView(Context context) {
|
||||
super(context);
|
||||
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
mPoints = new Point[3][3];
|
||||
}
|
||||
|
||||
/**
|
||||
* 画点和画线
|
||||
*/
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
if (!isInitPoint) {
|
||||
initPoint(); // 先初始化
|
||||
}
|
||||
canvasPoint(canvas); // 开始画点
|
||||
|
||||
// 开始画线
|
||||
if (mPointList.size() > 0) {
|
||||
Point b = null;
|
||||
Point a = mPointList.get(0);
|
||||
for (int i = 1; i < mPointList.size(); i++) {
|
||||
b = mPointList.get(i);
|
||||
canvasLine(a, b, canvas);
|
||||
a = b;
|
||||
}
|
||||
if (!isFinish) {
|
||||
canvasLine(a, mMousePoint, canvas);
|
||||
}
|
||||
}
|
||||
if(isFinish)
|
||||
{
|
||||
|
||||
try {
|
||||
Thread.sleep(700);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
changePointToNormal();
|
||||
postInvalidate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
//
|
||||
Display d=activity.getWindowManager().getDefaultDisplay();
|
||||
setMeasuredDimension(d.getWidth(),d.getWidth());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 手指点击手机屏幕
|
||||
*/
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
mMoveX = event.getX();
|
||||
mMoveY = event.getY();
|
||||
// 设置移动点的坐标
|
||||
mMousePoint.setX(mMoveX);
|
||||
mMousePoint.setY(mMoveY);
|
||||
Point mPoint = null;
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
isLineState = true;
|
||||
isFinish = false;
|
||||
// // 每次点击时就会将pointList中元素设置转化成普通状态
|
||||
// for (int i = 0; i < mPointList.size(); i++) {
|
||||
// mPointList.get(i).setState(Point.BITMAP_NORMAL);
|
||||
// }
|
||||
// // 将pointList中的元素清除掉
|
||||
// mPointList.clear();
|
||||
changePointToNormal();
|
||||
// 判断是否点中了九宫格中的点
|
||||
mPoint = getIsSelectedPoint(mMoveX, mMoveY);
|
||||
if (mPoint != null) {
|
||||
isSelect = true;
|
||||
}
|
||||
break;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
if (isSelect == true) {
|
||||
mPoint = getIsSelectedPoint(mMoveX, mMoveY);
|
||||
}
|
||||
|
||||
break;
|
||||
case MotionEvent.ACTION_UP:
|
||||
isFinish = true;
|
||||
isSelect = false;
|
||||
// 规定至少要有4个点被连线才有可能是正确
|
||||
// 其他种情况都是错误的
|
||||
if (mPointList.size() >= 4) {// 正确情况
|
||||
for (int j = 0; j < mPointList.size(); j++) {
|
||||
mPassword += mPointList.get(j).getIndex();
|
||||
}
|
||||
Log.i("password",mPassword);
|
||||
//将连线后得到的密码传给activity
|
||||
mListener.getStringPassword(mPassword);
|
||||
mPassword = "";
|
||||
//经过activity判断传过来是否正确
|
||||
if (mListener.isPassword()) {
|
||||
for (int i = 0; i < mPointList.size(); i++) {
|
||||
mPointList.get(i).setState(com.example.administrator.myapplication.widget.patternlock.Point.BITMAP_PRESS);
|
||||
|
||||
}
|
||||
isLineState = true;
|
||||
} else {
|
||||
for (int i = 0; i < mPointList.size(); i++) {
|
||||
mPointList.get(i).setState(com.example.administrator.myapplication.widget.patternlock.Point.BITMAP_ERROR);
|
||||
|
||||
}
|
||||
Log.i("correct","is not correct");
|
||||
isLineState = false;
|
||||
}
|
||||
// 错误情况
|
||||
} else if (mPointList.size() < 4 && mPointList.size() > 1) {
|
||||
for (int i = 0; i < mPointList.size(); i++) {
|
||||
mPointList.get(i).setState(com.example.administrator.myapplication.widget.patternlock.Point.BITMAP_ERROR);
|
||||
Snackbar.make(this,"为了您的App安全,手势至少得包含4个点",Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
isLineState = false;
|
||||
// 如果只有一个点被点中时为普通情况
|
||||
} else if (mPointList.size() == 1) {
|
||||
for (int i = 0; i < mPointList.size(); i++) {
|
||||
mPointList.get(i).setState(com.example.administrator.myapplication.widget.patternlock.Point.BITMAP_NORMAL);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
// 将mPoint添加到pointList中
|
||||
if (isSelect && mPoint != null) {
|
||||
if (mPoint.getState() == com.example.administrator.myapplication.widget.patternlock.Point.BITMAP_NORMAL) {
|
||||
mPoint.setState(com.example.administrator.myapplication.widget.patternlock.Point.BITMAP_PRESS);
|
||||
mPointList.add(mPoint);
|
||||
}
|
||||
}
|
||||
// Log.i("draw","draw -----");
|
||||
// 每次发生OnTouchEvent()后都刷新View
|
||||
postInvalidate();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @author htq
|
||||
*/
|
||||
private void changePointToNormal()
|
||||
{
|
||||
// 每次点击时就会将pointList中元素设置转化成普通状态
|
||||
for (int i = 0; i < mPointList.size(); i++) {
|
||||
mPointList.get(i).setState(com.example.administrator.myapplication.widget.patternlock.Point.BITMAP_NORMAL);
|
||||
}
|
||||
// 将pointList中的元素清除掉
|
||||
mPointList.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断九宫格中的某个点是否被点中了,或者某个点能否被连线
|
||||
*
|
||||
* @param moveX
|
||||
* @param moveY
|
||||
* @return
|
||||
*/
|
||||
private Point getIsSelectedPoint(float moveX, float moveY) {
|
||||
Point myPoint = null;
|
||||
for (int i = 0; i < mPoints.length; i++) {
|
||||
for (int j = 0; j < mPoints[i].length; j++) {
|
||||
if (mPoints[i][j].isWith(mPoints[i][j], moveX, moveY,
|
||||
mPointRadius)) {
|
||||
myPoint = mPoints[i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return myPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* 画线
|
||||
*
|
||||
* @param a 起始点
|
||||
* @param b 目的点
|
||||
* @param canvas 画布
|
||||
*/
|
||||
private void canvasLine(Point a, Point b, Canvas canvas) {
|
||||
// Math.sqrt(平方+平方)
|
||||
float abInstance = (float) Math.sqrt(
|
||||
(a.getX() - b.getX()) * (a.getX() - b.getX())
|
||||
+ (a.getY() - b.getY()) * (a.getY() - b.getY())
|
||||
);
|
||||
canvas.rotate(com.example.administrator.myapplication.widget.patternlock.RotateDegrees.getDegrees(a, b), a.getX(), a.getY());
|
||||
|
||||
mMatrix.setScale(abInstance / mLineHeight, 1);
|
||||
mMatrix.postTranslate(a.getX(), a.getY());
|
||||
if (isLineState) {
|
||||
canvas.drawBitmap(mLinePressed, mMatrix, mPaint);
|
||||
} else {
|
||||
canvas.drawBitmap(mLineError, mMatrix, mPaint);
|
||||
}
|
||||
|
||||
canvas.rotate(-com.example.administrator.myapplication.widget.patternlock.RotateDegrees.getDegrees(a, b), a.getX(), a.getY());
|
||||
}
|
||||
|
||||
/**
|
||||
* 画点
|
||||
*
|
||||
* @param canvas
|
||||
*/
|
||||
private void canvasPoint(Canvas canvas) {
|
||||
|
||||
for (int i = 0; i < mPoints.length; i++) {
|
||||
for (int j = 0; j < mPoints[i].length; j++) {
|
||||
if (mPoints[i][j].getState() == com.example.administrator.myapplication.widget.patternlock.Point.BITMAP_NORMAL) {
|
||||
canvas.drawBitmap(mBitmapNormal,
|
||||
mPoints[i][j].getX() - mPointRadius,
|
||||
mPoints[i][j].getY() - mPointRadius, mPaint);
|
||||
} else if (mPoints[i][j].getState() == com.example.administrator.myapplication.widget.patternlock.Point.BITMAP_PRESS) {
|
||||
canvas.drawBitmap(mBitmapPressed,
|
||||
mPoints[i][j].getX() - mPointRadius,
|
||||
mPoints[i][j].getY() - mPointRadius, mPaint);
|
||||
} else {
|
||||
canvas.drawBitmap(mBitmapError,
|
||||
mPoints[i][j].getX() - mPointRadius,
|
||||
mPoints[i][j].getY() - mPointRadius, mPaint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 实例化九宫格中所有点和所有的资源图片
|
||||
*/
|
||||
private void initPoint() {
|
||||
// 获取View的宽高
|
||||
mScreenWidth = getWidth();
|
||||
mScreenHeight = getHeight();
|
||||
if (mScreenHeight > mScreenWidth) {
|
||||
// 获取y轴上的偏移量
|
||||
mScreenHeightOffSet = (mScreenHeight - mScreenWidth) / 2;
|
||||
// 将屏幕高的变量设置成与宽相等,目的是为了new Point(x,y)时方便操作
|
||||
mScreenHeight = mScreenWidth;
|
||||
} else {
|
||||
// 获取x轴上的偏移量
|
||||
mScreenWidthOffSet = (mScreenWidth - mScreenHeight) / 2;
|
||||
// 将屏幕宽的变量设置成与高相等,目的是为了new Point(x,y)时方便操作
|
||||
mScreenWidth = mScreenHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* 实例化所有的资源图片
|
||||
*/
|
||||
mBitmapError = BitmapFactory.decodeResource(getResources(), R.drawable.bitmap_error);
|
||||
mBitmapNormal = BitmapFactory.decodeResource(getResources(), R.drawable.bitmap_normal);
|
||||
mBitmapPressed = BitmapFactory.decodeResource(getResources(), R.drawable.bitmap_pressed);
|
||||
mLineError = BitmapFactory.decodeResource(getResources(), R.drawable.line_error);
|
||||
mLinePressed = BitmapFactory.decodeResource(getResources(), R.drawable.line_pressed);
|
||||
|
||||
mPointRadius = mBitmapNormal.getWidth() / 2;
|
||||
mLineHeight = mLinePressed.getHeight();
|
||||
|
||||
/**
|
||||
* 开始实例化九宫格中点
|
||||
*/
|
||||
mPoints[0][0] = new Point(mScreenWidthOffSet + mScreenWidth / 4,
|
||||
mScreenHeightOffSet + mScreenHeight / 4);
|
||||
mPoints[0][1] = new Point(mScreenWidthOffSet + mScreenWidth / 2,
|
||||
mScreenHeightOffSet + mScreenHeight / 4);
|
||||
mPoints[0][2] = new Point(mScreenWidthOffSet + mScreenWidth * 3 / 4,
|
||||
mScreenHeightOffSet + mScreenHeight / 4);
|
||||
|
||||
mPoints[1][0] = new Point(mScreenWidthOffSet + mScreenWidth / 4,
|
||||
mScreenHeightOffSet + mScreenHeight / 2);
|
||||
mPoints[1][1] = new Point(mScreenWidthOffSet + mScreenWidth / 2,
|
||||
mScreenHeightOffSet + mScreenHeight / 2);
|
||||
mPoints[1][2] = new Point(mScreenWidthOffSet + mScreenWidth * 3 / 4,
|
||||
mScreenHeightOffSet + mScreenHeight / 2);
|
||||
|
||||
mPoints[2][0] = new Point(mScreenWidthOffSet + mScreenWidth / 4,
|
||||
mScreenHeightOffSet + mScreenHeight * 3 / 4);
|
||||
mPoints[2][1] = new Point(mScreenWidthOffSet + mScreenWidth / 2,
|
||||
mScreenHeightOffSet + mScreenHeight * 3 / 4);
|
||||
mPoints[2][2] = new Point(mScreenWidthOffSet + mScreenWidth * 3 / 4,
|
||||
mScreenHeightOffSet + mScreenHeight * 3 / 4);
|
||||
|
||||
|
||||
// 设置九宫格中的各个index
|
||||
int index = 1;
|
||||
for (int i = 0; i < mPoints.length; i++) {
|
||||
for (int j = 0; j < mPoints[i].length; j++) {
|
||||
mPoints[i][j].setIndex(index + "");
|
||||
// 在没有任何操作的情况下默認点的状态
|
||||
mPoints[i][j].setState(com.example.administrator.myapplication.widget.patternlock.Point.BITMAP_NORMAL);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
// 将isInitPoint设置为true
|
||||
isInitPoint = true;
|
||||
}
|
||||
|
||||
public interface OnLockListener {
|
||||
public void getStringPassword(String password);
|
||||
|
||||
|
||||
// public void setErrorMsg(String msg);
|
||||
// public void setSuccessMsg(String msg);
|
||||
public boolean isPassword();
|
||||
}
|
||||
|
||||
|
||||
public void setLockListener(OnLockListener listener) {
|
||||
this.mListener = listener;
|
||||
}
|
||||
public void setActivityContext(Activity aty){this.activity=aty;}
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
package com.example.administrator.myapplication.widget.patternlock;
|
||||
|
||||
public class Point {
|
||||
public static int BITMAP_NORMAL = 0; // 正常
|
||||
public static int BITMAP_ERROR = 1; // 错误
|
||||
public static int BITMAP_PRESS = 2; // 按下
|
||||
|
||||
//九宫格中的点的下标(即每个点代表一个值)
|
||||
private String index;
|
||||
//点的状态
|
||||
private int state;
|
||||
//点的坐标
|
||||
private float x;
|
||||
private float y;
|
||||
|
||||
public Point() {
|
||||
super();
|
||||
}
|
||||
|
||||
public Point(int x, int y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public String getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public int getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public float getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public float getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public void setIndex(String index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public void setState(int state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public void setX(float x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public void setY(float y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断屏幕上的九宫格中的点能否可以进行连线
|
||||
*
|
||||
* @param a
|
||||
* @param moveX
|
||||
* @param moveY
|
||||
* @param radius 点bitmap的半径
|
||||
* @return 布尔型
|
||||
*/
|
||||
public boolean isWith(Point a, float moveX, float moveY, float radius) {
|
||||
float result = (float) Math.sqrt((a.getX() - moveX)
|
||||
* (a.getX() - moveX) + (a.getY() - moveY)
|
||||
* (a.getY() - moveY));
|
||||
if (result < 5 * radius / 4) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
package com.example.administrator.myapplication.widget.patternlock;
|
||||
|
||||
public class RotateDegrees {
|
||||
|
||||
public static float getDegrees(Point a, Point b) {
|
||||
float degrees = 0;
|
||||
float ax = a.getX();
|
||||
float ay = a.getY();
|
||||
float bx = b.getX();
|
||||
float by = b.getY();
|
||||
|
||||
if (ax == bx) {
|
||||
if (by > ay) {
|
||||
degrees = 90;
|
||||
} else {
|
||||
degrees = 270;
|
||||
}
|
||||
} else if (by == ay) {
|
||||
if (ax > bx) {
|
||||
degrees = 180;
|
||||
} else {
|
||||
degrees = 0;
|
||||
}
|
||||
} else {
|
||||
if (ax > bx) {
|
||||
if (ay > by) { // 第三象限
|
||||
degrees = 180 + (float) (Math.atan2(ay - by, ax - bx) * 180 / Math.PI);
|
||||
} else { // 第二象限
|
||||
degrees = 180 - (float) (Math.atan2(by - ay, ax - bx) * 180 / Math.PI);
|
||||
}
|
||||
} else {
|
||||
if (ay > by) { // 第四象限
|
||||
degrees = 360 - (float) (Math.atan2(ay - by, bx - ax) * 180 / Math.PI);
|
||||
} else { // 第一象限
|
||||
degrees = (float) (Math.atan2(by - ay, bx - ax) * 180 / Math.PI);
|
||||
}
|
||||
}
|
||||
}
|
||||
return degrees;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<scale
|
||||
android:fromXScale="0.3" android:toXScale="1.0"
|
||||
android:fromYScale="0.3" android:toYScale="1.0"
|
||||
android:pivotX="50%" android:pivotY="100%"
|
||||
android:duration="@android:integer/config_shortAnimTime"
|
||||
/>
|
||||
<alpha
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
android:fromAlpha="0.0" android:toAlpha="1.0"
|
||||
android:duration="@android:integer/config_shortAnimTime"
|
||||
/>
|
||||
</set>
|
|
@ -1,14 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<scale
|
||||
android:fromXScale="1.0" android:toXScale="0.3"
|
||||
android:fromYScale="1.0" android:toYScale="0.3"
|
||||
android:pivotX="50%" android:pivotY="100%"
|
||||
android:duration="@android:integer/config_shortAnimTime"
|
||||
/>
|
||||
<alpha
|
||||
android:interpolator="@android:anim/accelerate_interpolator"
|
||||
android:fromAlpha="1.0" android:toAlpha="0.0"
|
||||
android:duration="@android:integer/config_shortAnimTime"
|
||||
/>
|
||||
</set>
|
Before Width: | Height: | Size: 321 B |
Before Width: | Height: | Size: 370 B |
Before Width: | Height: | Size: 18 KiB |