Skip to content

Commit

Permalink
HG : Add GifViewLayout to be able to pause and see a Pause icon
Browse files Browse the repository at this point in the history
  • Loading branch information
RoiSoleil committed Jun 23, 2013
1 parent 7776d3a commit 120a50e
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 3 deletions.
2 changes: 1 addition & 1 deletion AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:minSdkVersion="14"
android:targetSdkVersion="17" />

</manifest>
2 changes: 1 addition & 1 deletion bin/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:minSdkVersion="14"
android:targetSdkVersion="17" />

</manifest>
6 changes: 5 additions & 1 deletion bin/R.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
int attr gif 0x7f010000
int attr gifViewStyle 0x7f010002
int attr paused 0x7f010001
int style Widget_GifView 0x7f020000
int drawable pause 0x7f020000
int layout pause 0x7f030000
int string pause 0x7f040001
int string play 0x7f040000
int style Widget_GifView 0x7f050000
int[] styleable CustomTheme { 0x7f010002 }
int styleable CustomTheme_gifViewStyle 0
int[] styleable GifView { 0x7f010000, 0x7f010001 }
Expand Down
Binary file modified bin/gifview.jar
Binary file not shown.
Binary file added res/drawable-mdpi/pause.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions res/layout/pause.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?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" >

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:contentDescription="@string/pause"
android:src="@drawable/pause" />

</RelativeLayout>
6 changes: 6 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="play">Play</string>
<string name="pause">Pause</string>

</resources>
59 changes: 59 additions & 0 deletions src/org/roisoleil/gifview/GifViewLayout.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package org.roisoleil.gifview;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.FrameLayout;

public class GifViewLayout extends FrameLayout implements OnClickListener {

protected GifView mGifView;

protected View mPauseView;

public GifViewLayout(Context context) {
this(context, null);
}

public GifViewLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}

public GifViewLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mGifView = createGifView(context, attrs);
mPauseView = createPauseView();
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
addView(mGifView, params);
addView(mPauseView, params);
}

protected GifView createGifView(Context context, AttributeSet attrs) {
GifView gifView = new GifView(context, attrs,
R.styleable.CustomTheme_gifViewStyle);
gifView.setOnClickListener(this);
return gifView;
}

protected View createPauseView() {
LayoutInflater layoutInflater = LayoutInflater.from(getContext());
View view = layoutInflater.inflate(R.layout.pause, this, false);
view.setVisibility(View.GONE);
view.setOnClickListener(this);
return view;
}

@Override
public void onClick(View v) {
if (mGifView.isPaused()) {
mPauseView.setVisibility(View.GONE);
mGifView.setPaused(false);
} else {
mPauseView.setVisibility(View.VISIBLE);
mGifView.setPaused(true);
}
}
}

0 comments on commit 120a50e

Please sign in to comment.