Welcome to mirror list, hosted at ThFree Co, Russian Federation.

FullScreenGalleryFragment.java « gallery « maps « mapswithme « com « src « android - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f9353b1187dfb006ac6761aca3825684f6c62fd6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package com.mapswithme.maps.gallery;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.Target;
import com.mapswithme.maps.R;
import com.mapswithme.maps.base.BaseMwmFragment;

public class FullScreenGalleryFragment extends BaseMwmFragment
{
  static final String ARGUMENT_IMAGE = "argument_image";

  @Nullable
  private Image mImage;

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

  @Override
  public void onViewCreated(View view, @Nullable Bundle savedInstanceState)
  {
    super.onViewCreated(view, savedInstanceState);
    readArguments();

    if (mImage != null)
    {
      ImageView imageView = (ImageView) view.findViewById(R.id.iv__image);
      final View progress = view.findViewById(R.id.pb__loading_image);
      Glide.with(view.getContext())
           .load(mImage.getUrl())
           .listener(new RequestListener<String, GlideDrawable>()
           {
             @Override
             public boolean onException(Exception e, String model, Target<GlideDrawable> target,
                                        boolean isFirstResource)
             {
               if (isVisible())
               {
                 progress.setVisibility(View.GONE);
                 Toast.makeText(getContext(), getString(R.string.download_failed),
                                Toast.LENGTH_LONG).show();
               }
               return false;
             }

             @Override
             public boolean onResourceReady(GlideDrawable resource, String model,
                                            Target<GlideDrawable> target, boolean isFromMemoryCache,
                                            boolean isFirstResource)
             {
               if (isVisible())
                progress.setVisibility(View.GONE);
               return false;
             }
           })
           .into(imageView);
    }
  }

  private void readArguments()
  {
    Bundle args = getArguments();
    if (args != null)
      mImage = args.getParcelable(ARGUMENT_IMAGE);
  }
}