-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
241 changed files
with
15,718 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
apply plugin: 'com.android.library' | ||
|
||
|
||
|
||
android { | ||
compileSdkVersion 25 | ||
buildToolsVersion "26.0.0" | ||
|
||
defaultConfig { | ||
minSdkVersion 14 | ||
} | ||
|
||
lintOptions { | ||
abortOnError false | ||
} | ||
buildToolsVersion '25.0.0' | ||
} | ||
|
||
dependencies { | ||
compile 'com.pnikosis:materialish-progress:1.0' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
POM_NAME=SweetAlertDialog-Library | ||
POM_ARTIFACT_ID=library | ||
POM_PACKAGING=aar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="cn.pedant.SweetAlert" | ||
android:versionCode="2" | ||
android:versionName="1.1"> | ||
|
||
<uses-sdk | ||
android:minSdkVersion="9" | ||
android:targetSdkVersion="17" /> | ||
|
||
<application /> | ||
|
||
</manifest> |
89 changes: 89 additions & 0 deletions
89
SweetDialog/src/main/java/cn/pedant/SweetAlert/OptAnimationLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package cn.pedant.SweetAlert; | ||
|
||
import android.content.Context; | ||
import android.content.res.Resources; | ||
import android.content.res.XmlResourceParser; | ||
import android.util.AttributeSet; | ||
import android.util.Xml; | ||
import android.view.animation.*; | ||
import org.xmlpull.v1.XmlPullParser; | ||
import org.xmlpull.v1.XmlPullParserException; | ||
|
||
import java.io.IOException; | ||
|
||
public class OptAnimationLoader { | ||
|
||
public static Animation loadAnimation(Context context, int id) | ||
throws Resources.NotFoundException { | ||
|
||
XmlResourceParser parser = null; | ||
try { | ||
parser = context.getResources().getAnimation(id); | ||
return createAnimationFromXml(context, parser); | ||
} catch (XmlPullParserException ex) { | ||
Resources.NotFoundException rnf = new Resources.NotFoundException("Can't load animation resource ID #0x" + | ||
Integer.toHexString(id)); | ||
rnf.initCause(ex); | ||
throw rnf; | ||
} catch (IOException ex) { | ||
Resources.NotFoundException rnf = new Resources.NotFoundException("Can't load animation resource ID #0x" + | ||
Integer.toHexString(id)); | ||
rnf.initCause(ex); | ||
throw rnf; | ||
} finally { | ||
if (parser != null) parser.close(); | ||
} | ||
} | ||
|
||
private static Animation createAnimationFromXml(Context c, XmlPullParser parser) | ||
throws XmlPullParserException, IOException { | ||
|
||
return createAnimationFromXml(c, parser, null, Xml.asAttributeSet(parser)); | ||
} | ||
|
||
private static Animation createAnimationFromXml(Context c, XmlPullParser parser, | ||
AnimationSet parent, AttributeSet attrs) throws XmlPullParserException, IOException { | ||
|
||
Animation anim = null; | ||
|
||
// Make sure we are on a start tag. | ||
int type; | ||
int depth = parser.getDepth(); | ||
|
||
while (((type=parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) | ||
&& type != XmlPullParser.END_DOCUMENT) { | ||
|
||
if (type != XmlPullParser.START_TAG) { | ||
continue; | ||
} | ||
|
||
String name = parser.getName(); | ||
|
||
if (name.equals("set")) { | ||
anim = new AnimationSet(c, attrs); | ||
createAnimationFromXml(c, parser, (AnimationSet)anim, attrs); | ||
} else if (name.equals("alpha")) { | ||
anim = new AlphaAnimation(c, attrs); | ||
} else if (name.equals("scale")) { | ||
anim = new ScaleAnimation(c, attrs); | ||
} else if (name.equals("rotate")) { | ||
anim = new RotateAnimation(c, attrs); | ||
} else if (name.equals("translate")) { | ||
anim = new TranslateAnimation(c, attrs); | ||
} else { | ||
try { | ||
anim = (Animation) Class.forName(name).getConstructor(Context.class, AttributeSet.class).newInstance(c, attrs); | ||
} catch (Exception te) { | ||
throw new RuntimeException("Unknown animation name: " + parser.getName() + " error:" + te.getMessage()); | ||
} | ||
} | ||
|
||
if (parent != null) { | ||
parent.addAnimation(anim); | ||
} | ||
} | ||
|
||
return anim; | ||
|
||
} | ||
} |
167 changes: 167 additions & 0 deletions
167
SweetDialog/src/main/java/cn/pedant/SweetAlert/ProgressHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
package cn.pedant.SweetAlert; | ||
|
||
import android.content.Context; | ||
|
||
import com.pnikosis.materialishprogress.ProgressWheel; | ||
|
||
public class ProgressHelper { | ||
private ProgressWheel mProgressWheel; | ||
private boolean mToSpin; | ||
private float mSpinSpeed; | ||
private int mBarWidth; | ||
private int mBarColor; | ||
private int mRimWidth; | ||
private int mRimColor; | ||
private boolean mIsInstantProgress; | ||
private float mProgressVal; | ||
private int mCircleRadius; | ||
|
||
public ProgressHelper(Context ctx) { | ||
mToSpin = true; | ||
mSpinSpeed = 0.75f; | ||
mBarWidth = ctx.getResources().getDimensionPixelSize(R.dimen.common_circle_width) + 1; | ||
mBarColor = ctx.getResources().getColor(R.color.success_stroke_color); | ||
mRimWidth = 0; | ||
mRimColor = 0x00000000; | ||
mIsInstantProgress = false; | ||
mProgressVal = -1; | ||
mCircleRadius = ctx.getResources().getDimensionPixelOffset(R.dimen.progress_circle_radius); | ||
} | ||
|
||
public ProgressWheel getProgressWheel () { | ||
return mProgressWheel; | ||
} | ||
|
||
public void setProgressWheel (ProgressWheel progressWheel) { | ||
mProgressWheel = progressWheel; | ||
updatePropsIfNeed(); | ||
} | ||
|
||
private void updatePropsIfNeed () { | ||
if (mProgressWheel != null) { | ||
if (!mToSpin && mProgressWheel.isSpinning()) { | ||
mProgressWheel.stopSpinning(); | ||
} else if (mToSpin && !mProgressWheel.isSpinning()) { | ||
mProgressWheel.spin(); | ||
} | ||
if (mSpinSpeed != mProgressWheel.getSpinSpeed()) { | ||
mProgressWheel.setSpinSpeed(mSpinSpeed); | ||
} | ||
if (mBarWidth != mProgressWheel.getBarWidth()) { | ||
mProgressWheel.setBarWidth(mBarWidth); | ||
} | ||
if (mBarColor != mProgressWheel.getBarColor()) { | ||
mProgressWheel.setBarColor(mBarColor); | ||
} | ||
if (mRimWidth != mProgressWheel.getRimWidth()) { | ||
mProgressWheel.setRimWidth(mRimWidth); | ||
} | ||
if (mRimColor != mProgressWheel.getRimColor()) { | ||
mProgressWheel.setRimColor(mRimColor); | ||
} | ||
if (mProgressVal != mProgressWheel.getProgress()) { | ||
if (mIsInstantProgress) { | ||
mProgressWheel.setInstantProgress(mProgressVal); | ||
} else { | ||
mProgressWheel.setProgress(mProgressVal); | ||
} | ||
} | ||
if (mCircleRadius != mProgressWheel.getCircleRadius()) { | ||
mProgressWheel.setCircleRadius(mCircleRadius); | ||
} | ||
} | ||
} | ||
|
||
public void resetCount() { | ||
if (mProgressWheel != null) { | ||
mProgressWheel.resetCount(); | ||
} | ||
} | ||
|
||
public boolean isSpinning() { | ||
return mToSpin; | ||
} | ||
|
||
public void spin() { | ||
mToSpin = true; | ||
updatePropsIfNeed(); | ||
} | ||
|
||
public void stopSpinning() { | ||
mToSpin = false; | ||
updatePropsIfNeed(); | ||
} | ||
|
||
public float getProgress() { | ||
return mProgressVal; | ||
} | ||
|
||
public void setProgress(float progress) { | ||
mIsInstantProgress = false; | ||
mProgressVal = progress; | ||
updatePropsIfNeed(); | ||
} | ||
|
||
public void setInstantProgress(float progress) { | ||
mProgressVal = progress; | ||
mIsInstantProgress = true; | ||
updatePropsIfNeed(); | ||
} | ||
|
||
public int getCircleRadius() { | ||
return mCircleRadius; | ||
} | ||
|
||
/** | ||
* @param circleRadius units using pixel | ||
* **/ | ||
public void setCircleRadius(int circleRadius) { | ||
mCircleRadius = circleRadius; | ||
updatePropsIfNeed(); | ||
} | ||
|
||
public int getBarWidth() { | ||
return mBarWidth; | ||
} | ||
|
||
public void setBarWidth(int barWidth) { | ||
mBarWidth = barWidth; | ||
updatePropsIfNeed(); | ||
} | ||
|
||
public int getBarColor() { | ||
return mBarColor; | ||
} | ||
|
||
public void setBarColor(int barColor) { | ||
mBarColor = barColor; | ||
updatePropsIfNeed(); | ||
} | ||
|
||
public int getRimWidth() { | ||
return mRimWidth; | ||
} | ||
|
||
public void setRimWidth(int rimWidth) { | ||
mRimWidth = rimWidth; | ||
updatePropsIfNeed(); | ||
} | ||
|
||
public int getRimColor() { | ||
return mRimColor; | ||
} | ||
|
||
public void setRimColor(int rimColor) { | ||
mRimColor = rimColor; | ||
updatePropsIfNeed(); | ||
} | ||
|
||
public float getSpinSpeed() { | ||
return mSpinSpeed; | ||
} | ||
|
||
public void setSpinSpeed(float spinSpeed) { | ||
mSpinSpeed = spinSpeed; | ||
updatePropsIfNeed(); | ||
} | ||
} |
Oops, something went wrong.