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

ReviewFragment.java « review « maps « mapswithme « com « src « android - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: cfb39156e18f5750f8d813338e2b2e1e65c9ecdc (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
package com.mapswithme.maps.review;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.mapswithme.maps.R;
import com.mapswithme.maps.base.BaseMwmFragment;
import com.mapswithme.maps.widget.recycler.RecyclerClickListener;

import java.util.ArrayList;

public class ReviewFragment extends BaseMwmFragment implements RecyclerClickListener
{
  @Nullable
  private ArrayList<Review> mItems;
  @Nullable
  private String mRating;
  private int mRatingBase;
  @Nullable
  private String mUrl;

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

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

    if (mItems != null && mRating != null)
    {
      RecyclerView rvGallery = (RecyclerView) view.findViewById(R.id.rv__review);
      rvGallery.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
      rvGallery.setAdapter(new ReviewAdapter(mItems, this, mRating, mRatingBase));
    }
  }

  private void readArguments()
  {
    final Bundle arguments = getArguments();
    if (arguments == null)
      return;

    mItems = arguments.getParcelableArrayList(ReviewActivity.EXTRA_REVIEWS);
    mRating = arguments.getString(ReviewActivity.EXTRA_RATING);
    mRatingBase = arguments.getInt(ReviewActivity.EXTRA_RATING_BASE);
    mUrl = arguments.getString(ReviewActivity.EXTRA_RATING_URL);
  }

  @Override
  public void onItemClick(View v, int position)
  {
    if (mUrl == null)
      return;

    final Intent intent = new Intent(Intent.ACTION_VIEW);
    String url = mUrl;
    if (!url.startsWith("http://") && !url.startsWith("https://"))
      url = "http://" + url;
    intent.setData(Uri.parse(url));
    getContext().startActivity(intent);
  }
}