Skip to content

Commit

Permalink
Added a progress animation
Browse files Browse the repository at this point in the history
  • Loading branch information
Sendhil Grandhi committed May 25, 2016
1 parent 369ebc7 commit 6c9472c
Show file tree
Hide file tree
Showing 69 changed files with 238 additions and 928 deletions.
Binary file modified .gradle/2.10/taskArtifacts/cache.properties.lock
Binary file not shown.
Binary file modified .gradle/2.10/taskArtifacts/fileHashes.bin
Binary file not shown.
Binary file modified .gradle/2.10/taskArtifacts/fileSnapshots.bin
Binary file not shown.
Binary file modified .gradle/2.10/taskArtifacts/outputFileStates.bin
Binary file not shown.
Binary file modified .gradle/2.10/taskArtifacts/taskArtifacts.bin
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1,059 changes: 158 additions & 901 deletions .idea/workspace.xml

Large diffs are not rendered by default.

51 changes: 34 additions & 17 deletions yesno/src/main/java/com/sendhil/yesno/activity/YesNoActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import android.app.Activity;
import android.app.ProgressDialog;
import android.graphics.drawable.AnimationDrawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
Expand All @@ -16,6 +17,8 @@
import android.view.animation.AnimationSet;
import android.view.animation.ScaleAnimation;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
Expand All @@ -34,6 +37,9 @@ public class YesNoActivity extends Activity implements OnClickListener {
private static final String TAG = YesNoActivity.class.getSimpleName();
private GifImageView mGifImageView = null;
private ImageButton mImageButton = null;
private LinearLayout mLinearLayout = null;
private ImageView mImageView =null;
private AnimationSet animationSet = null;

@Override
public void onCreate(Bundle savedInstanceState) {
Expand All @@ -42,9 +48,10 @@ public void onCreate(Bundle savedInstanceState) {
mImageButton = (ImageButton) findViewById(R.id.my_button);
mImageButton.setOnClickListener(this);
mGifImageView = ((GifImageView)findViewById(R.id.gifImageView));
mLinearLayout = (LinearLayout) findViewById(R.id.loadingLayout);
mImageView = (ImageView) findViewById(R.id.loadingDrawable);


AnimationSet animationSet = new AnimationSet(true);
animationSet = new AnimationSet(true);


ScaleAnimation fade_in = new ScaleAnimation(2f, 0.75f, 2f, 0.75f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
Expand All @@ -64,20 +71,22 @@ public void onCreate(Bundle savedInstanceState) {

@Override
public void onClick(View arg0) {
ImageButton b = (ImageButton) findViewById(R.id.my_button);
b.setClickable(false);

toggleQuestion(false);

new LongRunningGetIO().execute();
}

private class LongRunningGetIO extends AsyncTask<Void, Void, Void> {

ProgressDialog mProgressDialog = new ProgressDialog(YesNoActivity.this);

@Override
protected void onPreExecute() {
super.onPreExecute();
mProgressDialog.setMessage(getString(R.string.loading_text));
mProgressDialog.show();
mLinearLayout.setVisibility(View.VISIBLE);
mImageView.setBackgroundResource(R.drawable.animation_progress);
AnimationDrawable frameAnimation = (AnimationDrawable) mImageView.getBackground();
frameAnimation.start();
}


Expand Down Expand Up @@ -112,8 +121,12 @@ public void onProgressChange(int percent) {

@Override
public void onComplete(GifDrawable result) {
mProgressDialog.dismiss();
mLinearLayout.setVisibility(View.GONE);
mGifImageView.setImageDrawable(result);
mImageButton.setClickable(true);
mImageButton.setVisibility(View.GONE);
mGifImageView.setVisibility(View.VISIBLE);
mLinearLayout.setVisibility(View.GONE);
}
});

Expand All @@ -127,23 +140,27 @@ public void onComplete(GifDrawable result) {
return null;
}

protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);

mImageButton.setClickable(true);
mImageButton.setVisibility(View.GONE);
mGifImageView.setVisibility(View.VISIBLE);
mProgressDialog.dismiss();
}
}

@Override
public void onBackPressed() {
if(mImageButton.getVisibility()==View.VISIBLE){
super.onBackPressed();
}else {
mImageButton.setVisibility(View.VISIBLE);
toggleQuestion(true);
mGifImageView.setVisibility(View.GONE);
}
}

private void toggleQuestion(boolean isEnabled){
if(isEnabled){
mImageButton.setClickable(true);
mImageButton.setVisibility(View.VISIBLE);
mImageButton.startAnimation(animationSet);
}else{
mImageButton.setClickable(false);
mImageButton.setVisibility(View.GONE);
mImageButton.setAnimation(null);
}
}
}
Binary file added yesno/src/main/res/drawable-hdpi/loading_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added yesno/src/main/res/drawable-hdpi/loading_10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added yesno/src/main/res/drawable-hdpi/loading_11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added yesno/src/main/res/drawable-hdpi/loading_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added yesno/src/main/res/drawable-hdpi/loading_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added yesno/src/main/res/drawable-hdpi/loading_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added yesno/src/main/res/drawable-hdpi/loading_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added yesno/src/main/res/drawable-hdpi/loading_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added yesno/src/main/res/drawable-hdpi/loading_7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added yesno/src/main/res/drawable-hdpi/loading_8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added yesno/src/main/res/drawable-hdpi/loading_9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added yesno/src/main/res/drawable-mdpi/loading_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added yesno/src/main/res/drawable-mdpi/loading_10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added yesno/src/main/res/drawable-mdpi/loading_11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added yesno/src/main/res/drawable-mdpi/loading_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added yesno/src/main/res/drawable-mdpi/loading_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added yesno/src/main/res/drawable-mdpi/loading_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added yesno/src/main/res/drawable-mdpi/loading_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added yesno/src/main/res/drawable-mdpi/loading_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added yesno/src/main/res/drawable-mdpi/loading_7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added yesno/src/main/res/drawable-mdpi/loading_8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added yesno/src/main/res/drawable-mdpi/loading_9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added yesno/src/main/res/drawable-xhdpi/loading_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added yesno/src/main/res/drawable-xhdpi/loading_10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added yesno/src/main/res/drawable-xhdpi/loading_11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added yesno/src/main/res/drawable-xhdpi/loading_2.png
Binary file added yesno/src/main/res/drawable-xhdpi/loading_3.png
Binary file added yesno/src/main/res/drawable-xhdpi/loading_4.png
Binary file added yesno/src/main/res/drawable-xhdpi/loading_5.png
Binary file added yesno/src/main/res/drawable-xhdpi/loading_6.png
Binary file added yesno/src/main/res/drawable-xhdpi/loading_7.png
Binary file added yesno/src/main/res/drawable-xhdpi/loading_8.png
Binary file added yesno/src/main/res/drawable-xhdpi/loading_9.png
Binary file added yesno/src/main/res/drawable-xxhdpi/loading_1.png
Binary file added yesno/src/main/res/drawable-xxhdpi/loading_10.png
Binary file added yesno/src/main/res/drawable-xxhdpi/loading_11.png
Binary file added yesno/src/main/res/drawable-xxhdpi/loading_2.png
Binary file added yesno/src/main/res/drawable-xxhdpi/loading_3.png
Binary file added yesno/src/main/res/drawable-xxhdpi/loading_4.png
Binary file added yesno/src/main/res/drawable-xxhdpi/loading_5.png
Binary file added yesno/src/main/res/drawable-xxhdpi/loading_6.png
Binary file added yesno/src/main/res/drawable-xxhdpi/loading_7.png
Binary file added yesno/src/main/res/drawable-xxhdpi/loading_8.png
Binary file added yesno/src/main/res/drawable-xxhdpi/loading_9.png
Binary file added yesno/src/main/res/drawable-xxxhdpi/loading_2.png
Binary file added yesno/src/main/res/drawable-xxxhdpi/loading_3.png
Binary file added yesno/src/main/res/drawable-xxxhdpi/loading_4.png
Binary file added yesno/src/main/res/drawable-xxxhdpi/loading_5.png
Binary file added yesno/src/main/res/drawable-xxxhdpi/loading_6.png
Binary file added yesno/src/main/res/drawable-xxxhdpi/loading_7.png
Binary file added yesno/src/main/res/drawable-xxxhdpi/loading_8.png
Binary file added yesno/src/main/res/drawable-xxxhdpi/loading_9.png
15 changes: 15 additions & 0 deletions yesno/src/main/res/drawable/animation_progress.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<animation-list android:id="@+id/selected" android:oneshot="false"
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/loading_1" android:duration="50" />
<item android:drawable="@drawable/loading_2" android:duration="50" />
<item android:drawable="@drawable/loading_3" android:duration="50" />
<item android:drawable="@drawable/loading_4" android:duration="50" />
<item android:drawable="@drawable/loading_5" android:duration="50" />
<item android:drawable="@drawable/loading_6" android:duration="50" />
<item android:drawable="@drawable/loading_7" android:duration="50" />
<item android:drawable="@drawable/loading_8" android:duration="50" />
<item android:drawable="@drawable/loading_9" android:duration="50" />
<item android:drawable="@drawable/loading_10" android:duration="50" />
<item android:drawable="@drawable/loading_11" android:duration="50" />
</animation-list>
38 changes: 29 additions & 9 deletions yesno/src/main/res/layout/main_layout.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#d6d7d7">
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#d6d7d7">

<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/question"
android:id="@+id/my_button"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/question"
android:id="@+id/my_button"/>

<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:id="@+id/loadingLayout"
android:visibility="gone"
android:orientation="vertical">

<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
android:id="@+id/loadingText"
android:textSize="16sp"
android:padding="10dp"
android:text="@string/loading_text"/>

<ImageView android:layout_width="wrap_content" android:layout_height="wrap_content"
android:id="@+id/loadingDrawable"
android:layout_gravity="center_horizontal"
android:background="@drawable/loading_1"/>

</LinearLayout>

<pl.droidsonroids.gif.GifImageView
android:id="@+id/gifImageView"
Expand Down
2 changes: 1 addition & 1 deletion yesno/yesno.iml
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@
<orderEntry type="library" exported="" name="support-v4-23.3.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.3" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.3.0" level="project" />
<orderEntry type="library" exported="" name="gson-2.4" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.3.0" level="project" />
<orderEntry type="library" exported="" name="gson-2.4" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="junit-4.12" level="project" />
</component>
</module>

0 comments on commit 6c9472c

Please sign in to comment.