forked from bumptech/glide
-
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.
Add fullscreen activity to GIF sample.
- Loading branch information
Showing
7 changed files
with
87 additions
and
11 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
59 changes: 59 additions & 0 deletions
59
samples/giphy/src/main/java/com/bumptech/glide/samples/giphy/FullscreenActivity.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,59 @@ | ||
package com.bumptech.glide.samples.giphy; | ||
|
||
import android.app.Activity; | ||
import android.content.ClipData; | ||
import android.content.ClipboardManager; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.ImageView; | ||
import com.bumptech.glide.Glide; | ||
import com.bumptech.glide.load.engine.DiskCacheStrategy; | ||
import com.bumptech.glide.load.resource.drawable.GlideDrawable; | ||
import com.bumptech.glide.load.resource.transcode.BitmapToGlideDrawableTranscoder; | ||
import com.google.gson.Gson; | ||
|
||
/** | ||
* An {@link android.app.Activity} for displaying full size original GIFs. | ||
*/ | ||
public class FullscreenActivity extends Activity { | ||
private static final String EXTRA_RESULT_JSON = "result_json"; | ||
|
||
public static Intent getIntent(Context context, Api.GifResult result) { | ||
Intent intent = new Intent(context, FullscreenActivity.class); | ||
intent.putExtra(EXTRA_RESULT_JSON, new Gson().toJson(result)); | ||
return intent; | ||
} | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.fullscreen_activity); | ||
|
||
String resultJson = getIntent().getStringExtra(EXTRA_RESULT_JSON); | ||
final Api.GifResult result = new Gson().fromJson(resultJson, Api.GifResult.class); | ||
|
||
ImageView gifView = (ImageView) findViewById(R.id.fullscreen_gif); | ||
|
||
gifView.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); | ||
ClipData clip = ClipData.newPlainText("giphy_url", result.images.original.url); | ||
clipboard.setPrimaryClip(clip); | ||
} | ||
}); | ||
|
||
Glide.with(this) | ||
.load(result.images.original.url) | ||
.diskCacheStrategy(DiskCacheStrategy.SOURCE) | ||
.thumbnail(Glide.with(this) | ||
.load(result) | ||
.asBitmap() | ||
.transcode(new BitmapToGlideDrawableTranscoder(this), GlideDrawable.class) | ||
.diskCacheStrategy(DiskCacheStrategy.SOURCE) | ||
) | ||
.into(gifView); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<ImageView | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:id="@+id/fullscreen_gif" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"/> |
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<ImageView xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:id="@+id/gif_view" | ||
android:layout_width="match_parent" | ||
android:layout_height="100dp" | ||
android:layout_height="125dp" | ||
android:contentDescription="@string/image_description" /> |