forked from RoiSoleil/GifView
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HG : Add GifViewLayout to be able to pause and see a Pause icon
- Loading branch information
Showing
8 changed files
with
86 additions
and
3 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
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
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,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> |
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,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="play">Play</string> | ||
<string name="pause">Pause</string> | ||
|
||
</resources> |
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,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); | ||
} | ||
} | ||
} |