Пример #1
0
 /**
  * *********************************************************************************************
  */
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_main);
   swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
   swipeRefreshLayout.setColorSchemeColors(Color.RED, Color.GREEN, Color.BLUE, Color.YELLOW);
   swipeRefreshLayout.setOnRefreshListener(
       new SwipeRefreshLayout.OnRefreshListener() {
         @Override
         public void onRefresh() {
           swipeRefreshLayout.setRefreshing(true);
           layoutManager.scrollToPosition(0);
           imageItemList.clear();
           currentPage = 1;
           refreshItems(currentPage);
         }
       });
   layoutManager = new GridLayoutManager(this, 3);
   layoutManager.setOrientation(GridLayoutManager.VERTICAL);
   sharkRecyclerView = (RecyclerView) findViewById(R.id.sharkRecyclerView);
   sharkRecyclerView.setLayoutManager(layoutManager);
   imageItemAdapter = new ImageItemAdapter(imageItemList, this);
   sharkRecyclerView.setAdapter(imageItemAdapter);
   sharkRecyclerView.setItemAnimator(new DefaultItemAnimator());
   addScrollListener();
 }
Пример #2
0
  /**
   * Sets the orientation of content display of this view
   *
   * @param orientation
   */
  public void setContentOrientation(int orientation) {
    if (orientation != CONTENT_ORIENTATION_HORIZONTAL
        && orientation != CONTENT_ORIENTATION_VERTICAL) return;
    if (mContentWrapper.getLayoutManager() == null) return;

    RecyclerView.LayoutManager lManager = mContentWrapper.getLayoutManager();
    if (lManager instanceof GridLayoutManager) {
      ((GridLayoutManager) lManager).setOrientation(orientation);
      mContentOrientation = orientation;
      mContentWrapper.invalidate();
    }
  }
  // Métodos de la interfaz
  @Override
  public void generarGridLayout() {
    GridLayoutManager glm = new GridLayoutManager(getActivity(), 3);
    glm.setOrientation(GridLayoutManager.VERTICAL);
    rvPerfilMascota.setLayoutManager(glm);

    Picasso.with(activity)
        .load(PerfilMascota.fotoUsuario)
        .placeholder(R.drawable.grumpy_cat_head)
        .into(imgFotoPerfil);

    tvNombrePerfil.setText(PerfilMascota.nombreUsuario);
  }
  private void setupAdapter() {

    GridLayoutManager gridLayoutManager = new GridLayoutManager(SearchActivity.this, 5);
    gridLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    gridLayoutManager.setSmoothScrollbarEnabled(true);

    searchAdapter = new SearchAdapter(this);
    searchAdapter.setCallback(SearchActivity.this);

    recyclerView.setLayoutManager(gridLayoutManager);
    recyclerView.setHasFixedSize(true);
    recyclerView.setAdapter(searchAdapter);
    recyclerView.addItemDecoration(new MarginDecoration(SearchActivity.this, R.dimen.material_4dp));
  }
 @Override
 public View onCreateView(
     LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   View view = inflater.inflate(R.layout.icon_fragment, container, false);
   Display display = getActivity().getWindowManager().getDefaultDisplay();
   Point size = new Point();
   display.getSize(size);
   int numOfRows = (int) (size.x / getResources().getDimension(R.dimen.size_of_grid_item));
   RecyclerView gridview = (RecyclerView) view.findViewById(R.id.icons_rv);
   GridLayoutManager layoutManager = new GridLayoutManager(view.getContext(), numOfRows);
   layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
   layoutManager.scrollToPosition(0);
   gridview.setLayoutManager(layoutManager);
   gridview.setHasFixedSize(true);
   gridview.addItemDecoration(new SpacesItemDecoration(10, 5));
   gridview.setAdapter(
       new IconsAdapter(view.getContext(), getArguments().getInt("iconsArrayId", 0)));
   return view;
 }
Пример #6
0
 @Override
 public void onListLoaded(String jsonResult) {
   try {
     if (jsonResult != null) {
       try {
         JSONObject jsonResponse = new JSONObject(jsonResult);
         JSONArray jsonMainNode = jsonResponse.optJSONArray("walls");
         for (int i = 0; i < jsonMainNode.length(); i++) {
           JSONObject jsonChildNode = jsonMainNode.getJSONObject(i);
           items.add(
               new WallpaperItem(
                   jsonChildNode.optString("name"),
                   jsonChildNode.optString("author"),
                   jsonChildNode.optString("url")));
         }
       } catch (JSONException e) {
         e.printStackTrace();
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
   RecyclerView gridview = (RecyclerView) findViewById(R.id.wall_rv);
   Display display = getWindowManager().getDefaultDisplay();
   Point size = new Point();
   display.getSize(size);
   (findViewById(R.id.progressBar_wall)).setVisibility(View.GONE);
   int numOfRows = (int) (size.x / getResources().getDimension(R.dimen.size_of_grid_item));
   GridLayoutManager layoutManager = new GridLayoutManager(this, 2);
   layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
   layoutManager.scrollToPosition(0);
   gridview.setLayoutManager(layoutManager);
   gridview.setHasFixedSize(true);
   gridview.addItemDecoration(new SpacesItemDecoration(8, 2));
   gridview.setAdapter(new WallAdapter(this, items, display));
 }
 /**
  * Sets the orientation of the layout. {@link android.support.v7.widget.LinearLayoutManager} will
  * do its best to keep scroll position.
  *
  * @param orientation {@link #HORIZONTAL} or {@link #VERTICAL}
  */
 public void setOrientation(int orientation) {
   if (gridManager == null) {
     throw new IllegalStateException("Error init of GridLayoutManager");
   }
   gridManager.setOrientation(orientation);
 }