Skip to content

Commit

Permalink
Migrate Simple Drawee sample to Vito
Browse files Browse the repository at this point in the history
Differential Revision: D50801804

fbshipit-source-id: 18a033b97518b01c99c88fb43b3dbcabdbf5274d
  • Loading branch information
oprisnik authored and facebook-github-bot committed Oct 31, 2023
1 parent 8670246 commit 9551d39
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ object ExampleDatabase {
ExampleCategory(
"Drawee",
listOf(
ExampleItem("Simple Drawee") { DraweeSimpleFragment() },
ExampleItem("Media Provider") { DraweeMediaPickerFragment() },
ExampleItem("Scale Type") { DraweeScaleTypeFragment() },
ExampleItem("Simple DraweeSpan") { DraweeSpanSimpleTextFragment() },
Expand Down Expand Up @@ -96,6 +95,7 @@ object ExampleDatabase {
"Vito Litho component with listener."),
ExampleItem("Vito Litho: Gallery") { FrescoVitoLithoGalleryFragment() },
ExampleItem("Vito View: Simple") { VitoViewSimpleFragment() },
ExampleItem("Vito View: Simple 2") { VitoSimpleFragment() },
ExampleItem("Vito View: Recycler") { VitoViewRecyclerFragment() },
ExampleItem("Vito View: Prefetch") { VitoViewPrefetchFragment() },
ExampleItem("Vito View: Kotlin Extensions") { VitoViewKtxFragment() },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,39 @@
* LICENSE file in the root directory of this source tree.
*/

package com.facebook.fresco.samples.showcase.drawee;
package com.facebook.fresco.samples.showcase.vito;

import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import androidx.annotation.Nullable;
import com.facebook.drawee.view.SimpleDraweeView;
import com.facebook.fresco.samples.showcase.BaseShowcaseFragment;
import com.facebook.fresco.samples.showcase.R;
import com.facebook.fresco.samples.showcase.misc.ImageUriProvider;
import com.facebook.fresco.vito.view.VitoView;

/** Simple drawee fragment that just displays an image. */
public class DraweeSimpleFragment extends BaseShowcaseFragment {
/** Simple Vito fragment that just displays an image. */
public class VitoSimpleFragment extends BaseShowcaseFragment {

@Nullable
@Override
public View onCreateView(
LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_drawee_simple, container, false);
return inflater.inflate(R.layout.fragment_vito_simple, container, false);
}

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
final Uri uri = sampleUris().createSampleUri(ImageUriProvider.ImageSize.M);

final SimpleDraweeView simpleDraweeView =
(SimpleDraweeView) view.findViewById(R.id.drawee_view);
simpleDraweeView.setImageURI(uri);
final ImageView imageView = (ImageView) view.findViewById(R.id.image);
VitoView.show(sampleUris().createSampleUri(), imageView);

view.findViewById(R.id.btn_random_uri)
.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
simpleDraweeView.setImageURI(sampleUris().createSampleUri());
VitoView.show(sampleUris().createSampleUri(), imageView);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
android:orientation="vertical"
>

<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/drawee_view"
<ImageView
android:id="@+id/image"
android:layout_width="@dimen/drawee_width_medium"
android:layout_height="@dimen/drawee_height_medium"
/>
Expand All @@ -19,7 +19,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_medium"
android:gravity="center"
android:text="@string/drawee_simple_help"
android:text="@string/vito_simple_help"
android:textAppearance="?android:attr/textAppearanceSmall"
/>

Expand Down
2 changes: 1 addition & 1 deletion samples/showcase/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<string name="action_settings">Settings</string>

<string name="drawee_simple_help">Basic SimpleDraweeView example that just sets the image URI.</string>
<string name="vito_simple_help">Basic Vito example that just sets the image URI.</string>

<string name="drawee_media_picker_help">Select an image by pressing one of the media picker buttons.</string>
<string name="drawee_media_picker_button_action_open_document">ACTION_OPEN_DOCUMENT</string>
Expand Down

0 comments on commit 9551d39

Please sign in to comment.