-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #98 from navasmdc/develop
Add ProgressDialog widget and fix bugs
- Loading branch information
Showing
9 changed files
with
193 additions
and
13 deletions.
There are no files selected for viewing
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
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,36 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:id="@+id/dialog_rootView" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:background="#55000000" | ||
android:padding="32dp" > | ||
|
||
<RelativeLayout | ||
android:id="@+id/contentDialog" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_centerInParent="true" | ||
android:background="@drawable/dialog_background" | ||
android:padding="24dp" > | ||
|
||
<com.gc.materialdesign.views.ProgressBarCircularIndeterminate | ||
android:id="@+id/progressBarCircularIndetermininate" | ||
android:layout_width="32dp" | ||
android:layout_height="32dp" | ||
android:layout_centerVertical="true" | ||
android:background="#1E88E5" /> | ||
|
||
<TextView | ||
android:id="@+id/title" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_centerVertical="true" | ||
android:layout_toRightOf="@+id/progressBarCircularIndetermininate" | ||
android:layout_marginLeft="8dp" | ||
android:text="Title" | ||
android:textAppearance="?android:attr/textAppearanceLarge" | ||
android:textColor="#000" /> | ||
</RelativeLayout> | ||
|
||
</RelativeLayout> |
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
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
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
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
139 changes: 139 additions & 0 deletions
139
MaterialDesign/src/com/gc/materialdesign/widgets/ProgressDialog.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,139 @@ | ||
package com.gc.materialdesign.widgets; | ||
|
||
import android.content.Context; | ||
import android.os.Bundle; | ||
import android.view.MotionEvent; | ||
import android.view.View; | ||
import android.view.View.OnTouchListener; | ||
import android.view.Window; | ||
import android.view.animation.Animation; | ||
import android.view.animation.Animation.AnimationListener; | ||
import android.view.animation.AnimationUtils; | ||
import android.widget.RelativeLayout; | ||
import android.widget.TextView; | ||
|
||
import com.gc.materialdesign.R; | ||
import com.gc.materialdesign.views.ButtonFlat; | ||
import com.gc.materialdesign.views.ProgressBarCircularIndeterminate; | ||
|
||
public class ProgressDialog extends android.app.Dialog{ | ||
|
||
Context context; | ||
View view; | ||
View backView; | ||
String title; | ||
TextView titleTextView; | ||
|
||
int progressColor = -1; | ||
|
||
public ProgressDialog(Context context,String title) { | ||
super(context, android.R.style.Theme_Translucent); | ||
this.title = title; | ||
this.context = context; | ||
} | ||
|
||
public ProgressDialog(Context context,String title, int progressColor) { | ||
super(context, android.R.style.Theme_Translucent); | ||
this.title = title; | ||
this.progressColor = progressColor; | ||
this.context = context; | ||
} | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
requestWindowFeature(Window.FEATURE_NO_TITLE); | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.progress_dialog); | ||
|
||
view = (RelativeLayout)findViewById(R.id.contentDialog); | ||
backView = (RelativeLayout)findViewById(R.id.dialog_rootView); | ||
backView.setOnTouchListener(new OnTouchListener() { | ||
|
||
@Override | ||
public boolean onTouch(View v, MotionEvent event) { | ||
if (event.getX() < view.getLeft() | ||
|| event.getX() >view.getRight() | ||
|| event.getY() > view.getBottom() | ||
|| event.getY() < view.getTop()) { | ||
dismiss(); | ||
} | ||
return false; | ||
} | ||
}); | ||
|
||
this.titleTextView = (TextView) findViewById(R.id.title); | ||
setTitle(title); | ||
if(progressColor != -1){ | ||
ProgressBarCircularIndeterminate progressBarCircularIndeterminate = (ProgressBarCircularIndeterminate) findViewById(R.id.progressBarCircularIndetermininate); | ||
progressBarCircularIndeterminate.setBackgroundColor(progressColor); | ||
} | ||
|
||
|
||
} | ||
|
||
@Override | ||
public void show() { | ||
// TODO 自动生成的方法存根 | ||
super.show(); | ||
// set dialog enter animations | ||
view.startAnimation(AnimationUtils.loadAnimation(context, R.anim.dialog_main_show_amination)); | ||
backView.startAnimation(AnimationUtils.loadAnimation(context, R.anim.dialog_root_show_amin)); | ||
} | ||
|
||
// GETERS & SETTERS | ||
|
||
public String getTitle() { | ||
return title; | ||
} | ||
|
||
public void setTitle(String title) { | ||
this.title = title; | ||
if(title == null) | ||
titleTextView.setVisibility(View.GONE); | ||
else{ | ||
titleTextView.setVisibility(View.VISIBLE); | ||
titleTextView.setText(title); | ||
} | ||
} | ||
|
||
public TextView getTitleTextView() { | ||
return titleTextView; | ||
} | ||
|
||
public void setTitleTextView(TextView titleTextView) { | ||
this.titleTextView = titleTextView; | ||
} | ||
|
||
@Override | ||
public void dismiss() { | ||
Animation anim = AnimationUtils.loadAnimation(context, R.anim.dialog_main_hide_amination); | ||
anim.setAnimationListener(new AnimationListener() { | ||
|
||
@Override | ||
public void onAnimationStart(Animation animation) { | ||
} | ||
|
||
@Override | ||
public void onAnimationRepeat(Animation animation) { | ||
} | ||
|
||
@Override | ||
public void onAnimationEnd(Animation animation) { | ||
view.post(new Runnable() { | ||
@Override | ||
public void run() { | ||
ProgressDialog.super.dismiss(); | ||
} | ||
}); | ||
|
||
} | ||
}); | ||
Animation backAnim = AnimationUtils.loadAnimation(context, R.anim.dialog_root_hide_amin); | ||
|
||
view.startAnimation(anim); | ||
backView.startAnimation(backAnim); | ||
} | ||
|
||
|
||
|
||
} |
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 |
---|---|---|
|
@@ -19,6 +19,6 @@ allprojects { | |
} | ||
|
||
group = "com.github.navasmdc" | ||
version = "1.1.1" | ||
version = "1.3" | ||
} | ||
|
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