private void bindListeners() {
    tv_title.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            toggleDirlistPop();
          }
        });

    // 图片列表
    GridLayoutManager mgr = new GridLayoutManager(this, 3);
    recycler_image.setLayoutManager(mgr);
    recycler_image.addItemDecoration(new GridSpacingItemDecoration(3, dp2px(5), false));
    imageAdapter = new ImageAdapter();
    recycler_image.setAdapter(imageAdapter);

    // 目录列表
    recycler_dir.setLayoutManager(new LinearLayoutManager(this));
    dirAdapter = new FolderAdapter();
    recycler_dir.setAdapter(dirAdapter);

    // 黑色图层
    view_layer.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            hideDirList();
          }
        });
  }
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.btn0:
       mRecyclerView.setAdapter(mAdapter);
       // 设置recyclerView的布局管理
       mRecyclerView.setLayoutManager(
           new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
       // 设置RecyclerView的Item间分割线
       mRecyclerView.addItemDecoration(mDivider);
       break;
     case R.id.btn1:
       mRecyclerView.removeItemDecoration(mDivider);
       mRecyclerView.setAdapter(mAdapter);
       // 设置recyclerView的竖直gridview布局管理
       mRecyclerView.setLayoutManager(new GridLayoutManager(this, 5));
       break;
     case R.id.btn2:
       mRecyclerView.removeItemDecoration(mDivider);
       mRecyclerView.setAdapter(mAdapter);
       // 设置recyclerView的水平gridview布局管理,需要确定item宽度
       mRecyclerView.setLayoutManager(
           new StaggeredGridLayoutManager(5, StaggeredGridLayoutManager.HORIZONTAL));
       break;
     case R.id.btn3:
       mRecyclerView.removeItemDecoration(mDivider);
       // 设置recyclerView瀑布流
       StaggeredAdapter adapter = new StaggeredAdapter(this, mDatas);
       mRecyclerView.setAdapter(adapter);
       mRecyclerView.setLayoutManager(
           new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
       break;
   }
 }
Beispiel #3
0
  private void initObjects(View root) {
    mDialog = new ProgressDialog(this);
    mDialog.setTitle(R.string.app_name);
    mDialog.setMessage("Fetching images...");

    mGridAdapter = new ImageGridAdapter();

    mSmallRecView = UiUtils.getView(root, R.id.MAIN_small_rec_view);
    mSmallRecView.setLayoutManager(new GridLayoutManager(this, 4));
    mSmallRecView.setAdapter(mGridAdapter);
    mSmallRecView.setAlpha(0f);
    mSmallRecView.setVisibility(View.VISIBLE);

    mBigRecView = UiUtils.getView(root, R.id.MAIN_big_rec_view);
    mBigRecView.setLayoutManager(new GridLayoutManager(this, 3));
    mBigRecView.setAdapter(mGridAdapter);
    mBigRecView.setVisibility(View.VISIBLE);
    mBigRecView.setAlpha(1f);

    UiUtils.getView(root, R.id.MAIN_root).setOnTouchListener(this);
    mSmallRecView.setOnTouchListener(this);
    mBigRecView.setOnTouchListener(this);

    mGestureDetector = new ScaleGestureDetector(this, this);
  }
Beispiel #4
0
 private void setLayoutManager(RecyclerView recyclerView) {
   if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
     recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
   } else {
     recyclerView.setLayoutManager(new GridLayoutManager(this, 3));
   }
 }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.add:
       adapter.addItem(1);
       break;
     case R.id.delete:
       adapter.deleteItem(1);
       break;
     case R.id.recycler_list_view: // ListView
       LinearLayoutManager manager = new LinearLayoutManager(this);
       mRecyclerView.setLayoutManager(manager);
       initSimpleAdapter();
       break;
     case R.id.recycler_grid_view: // 纵向GridView
       GridLayoutManager mGridLayoutManager = new GridLayoutManager(this, 3);
       mRecyclerView.setLayoutManager(mGridLayoutManager);
       initSimpleAdapter();
       break;
     case R.id.recycler_grid_view_hor: // 横向GridView
       StaggeredGridLayoutManager mStaggeredGridLayoutManager =
           new StaggeredGridLayoutManager(5, StaggeredGridLayoutManager.HORIZONTAL);
       mRecyclerView.setLayoutManager(mStaggeredGridLayoutManager);
       initSimpleAdapter();
       break;
     case R.id.waterfall: // 瀑布流
       initWaterFallAdapter();
       StaggeredGridLayoutManager waterfall =
           new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL);
       mRecyclerView.setLayoutManager(waterfall);
       break;
   }
   return super.onOptionsItemSelected(item);
 }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.action_vertical:
       currType = TYPE_VERTICAL;
       recyclerView.setLayoutManager(getLayoutManager(currType));
       break;
     case R.id.action_horizontal:
       currType = TYPE_HORIZONTAL;
       recyclerView.setLayoutManager(getLayoutManager(currType));
       break;
     case R.id.action_grid:
       currType = TYPE_GRID;
       recyclerView.setLayoutManager(getLayoutManager(currType));
       break;
     case R.id.action_staggered_v:
       currType = TYPE_STAGGERED_V;
       recyclerView.setLayoutManager(getLayoutManager(currType));
       break;
     case R.id.action_staggered_h:
       currType = TYPE_STAGGERED_H;
       recyclerView.setLayoutManager(getLayoutManager(currType));
       break;
     case R.id.action_multiple:
       startActivity(new Intent(this, MultipleItemActivity.class));
       break;
   }
   return true;
 }
  private void initRecyclerView() {
    bookAvailable = (ListView) findViewById(R.id.books_available_msg);
    bookAuthor = (RecyclerView) findViewById(R.id.books_author_msg);
    bookPublisher = (RecyclerView) findViewById(R.id.books_publisher_msg);

    getAvailableMsg();

    BookInfo authorMsg = new BookInfo();
    if (!BOOK_AUTHOR.equals("")) {
      authorMsg.title = BOOK_AUTHOR;
    } else {
      authorMsg.title = "没有找到";
    }
    authorMsg.subTitle = "作者";
    List<BookInfo> authorList = new ArrayList<>();
    authorList.add(authorMsg);

    BookInfo publisherMsg = new BookInfo();
    publisherMsg.title = BOOK_PUBLISHER;
    publisherMsg.subTitle = "出版社";
    List<BookInfo> publisherList = new ArrayList<>();
    publisherList.add(publisherMsg);

    BookInfoAdapter authorAdapter = new BookInfoAdapter(getApplicationContext(), authorList);
    BookInfoAdapter publisherAdapter = new BookInfoAdapter(getApplicationContext(), publisherList);

    bookAuthor.setAdapter(authorAdapter);
    bookAuthor.setLayoutManager(new LinearLayoutManager(getApplicationContext()));

    bookPublisher.setAdapter(publisherAdapter);
    bookPublisher.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
  }
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
	                         Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.fragment_browse, container, false);
		latestWallpaperIDs = new ArrayList<>();
		randomWallpapers = new ArrayList<>();
		mSfwSwitch = (Switch) view.findViewById(R.id.sfwSwitch);
		mSketchySwitch = (Switch) view.findViewById(R.id.sketchySwitch);
		mSfwSwitch.setChecked(true);
		//Latest
		mLatestRecyclerView = (RecyclerView) view.findViewById(R.id.latestRecycler);
		mLatestRecyclerView.setHasFixedSize(true);
		mLatestLayoutManager = new LinearLayoutManager(view.getContext(), LinearLayoutManager.HORIZONTAL, false);
		mLatestRecyclerView.setLayoutManager(mLatestLayoutManager);
		mLatestAdapter = new ImageRecyclerAdapter(latestWallpaperIDs);
		mLatestRecyclerView.setAdapter(mLatestAdapter);
		SharedPreferences mSharedPref = WallhavenBrowser.getContext().getSharedPreferences("com.sirkitboard.wallhavenbrowser",  WallhavenBrowser.getContext().MODE_PRIVATE);
		String purity = mSharedPref.getString("purity","100");
		mSfwSwitch.setChecked(purity.charAt(0) == '1');
		mSketchySwitch.setChecked(purity.charAt(1) == '1');
		//Random
		mRandomRecyclerView = (RecyclerView) view.findViewById(R.id.randomRecycler);
		mRandomRecyclerView.setHasFixedSize(true);
		mRandomLayoutManager = new LinearLayoutManager(view.getContext(), LinearLayoutManager.HORIZONTAL, false);
		mRandomRecyclerView.setLayoutManager(mRandomLayoutManager);
		mRandomAdapter = new ImageRecyclerAdapter(randomWallpapers);
		mRandomRecyclerView.setAdapter(mRandomAdapter);
		refresh();

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

    viewBackdrops = (BackdropViewPager) view.findViewById(R.id.backdrop_pager);
    viewTitle = (TextView) view.findViewById(R.id.title);
    viewPoster = (ImageView) view.findViewById(R.id.poster);
    viewProgressBar = (ProgressBar) view.findViewById(R.id.progress_bar);
    viewTagLine = (TextView) view.findViewById(R.id.tagline);
    viewReleaseDate = (TextView) view.findViewById(R.id.release_date);
    viewRuntime = (TextView) view.findViewById(R.id.runtime);
    viewOverview = (TextView) view.findViewById(R.id.overview);
    viewGenres = (TextView) view.findViewById(R.id.genres);

    viewCastList = (RecyclerView) view.findViewById(R.id.cast_list);
    viewCastList.setHasFixedSize(true);
    viewCastList.setLayoutManager(
        new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false));

    viewCrewList = (RecyclerView) view.findViewById(R.id.crew_list);
    viewCrewList.setHasFixedSize(true);
    viewCrewList.setLayoutManager(
        new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false));

    viewReviews = (ReviewsView) view.findViewById(R.id.reviews_view);

    return view;
  }
 private void initRecyclerView() {
   guideRecyclerView.setAdapter(guideAdapter);
   guideRecyclerView.addItemDecoration(AppTools.defaultHorizontalDecoration());
   guideRecyclerView.setLayoutManager(new LinearLayoutManager(this));
   recyclerView.addItemDecoration(
       new HorizontalDividerItemDecoration.Builder(this)
           .colorResId(R.color.color_bg_gravy)
           .sizeResId(R.dimen.large_margin_15dp)
           .build());
   recyclerView.setLayoutManager(linearLayoutManager);
   recyclerView.setAdapter(commonBinderAdapter);
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    setHasOptionsMenu(true);
    View rootView = inflater.inflate(R.layout.fragment_movie_detail, container, false);
    ButterKnife.bind(this, rootView);
    CustomLayoutManager trailerLayoutManager = new CustomLayoutManager(getActivity());
    lvTrailers.setLayoutManager(trailerLayoutManager);

    CustomLayoutManager reviewsLayoutManager = new CustomLayoutManager(getActivity());
    lvReviews.setLayoutManager(reviewsLayoutManager);

    return rootView;
  }
Beispiel #12
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_nearby);
    mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    // If the adapter is null, then Bluetooth is not supported
    if (mBluetoothAdapter == null) {
      Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show();
      finish();
    }
    doDiscovery();
    setResult(Activity.RESULT_CANCELED);

    ArrayList<String> pairedDevices = new ArrayList<String>();
    mNewDevicesArrayAdapter = new ArrayList<String>();
    mRecyclerView = (RecyclerView) findViewById(R.id.paired_recycler_view);
    mRecyclerView.setHasFixedSize(true);
    mAdapter = new BluetoothRecyclerAdapter(this, pairedDevices);
    mRecyclerView.setAdapter(mAdapter);
    mLayoutManager = new LinearLayoutManager(this);
    mRecyclerView.setLayoutManager(mLayoutManager);

    RecyclerView mNewRecyclerView = (RecyclerView) findViewById(R.id.available_recycler_view);
    mNewRecyclerView.setHasFixedSize(true);
    RecyclerView.Adapter mNewAdapter = new BluetoothRecyclerAdapter(this, mNewDevicesArrayAdapter);
    mNewRecyclerView.setAdapter(mNewAdapter);
    RecyclerView.LayoutManager mNewLayoutManager = new LinearLayoutManager(this);
    mNewRecyclerView.setLayoutManager(mNewLayoutManager);

    IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
    this.registerReceiver(mReceiver, filter);

    // Register for broadcasts when discovery has finished
    filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
    this.registerReceiver(mReceiver, filter);

    Set<BluetoothDevice> pairedDevicesSet = mBluetoothAdapter.getBondedDevices();

    // If there are paired devices, add each one to the ArrayAdapter
    if (pairedDevicesSet.size() > 0) {
      findViewById(R.id.title_paired_devices).setVisibility(View.VISIBLE);
      for (BluetoothDevice device : pairedDevicesSet) {
        pairedDevices.add(device.getName() + "\n" + device.getAddress());
      }
    } else {
      String noDevices = getResources().getText(R.string.none_paired).toString();
      pairedDevices.add(noDevices);
    }
  }
 public void viewSwitcher(View v) {
   Editor editor = categoryViewShared.edit();
   if (myAdapter.getViewType() == MyAdapter.LAYOUT_ITEM_GRID) {
     recyclerView.setLayoutManager(new LinearLayoutManager(this));
     viewSwticherImageView.setImageDrawable(getResources().getDrawable(R.drawable.ic_grid));
     myAdapter.setType(MyAdapter.LAYOUT_ITEM_LIST);
     editor.putBoolean("isGridView", false);
   } else {
     recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
     myAdapter.setType(MyAdapter.LAYOUT_ITEM_GRID);
     viewSwticherImageView.setImageDrawable(getResources().getDrawable(R.drawable.ic_list));
     editor.putBoolean("isGridView", true);
   }
   editor.commit();
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_expenses_details);

    db = DatabaseHandler.getInstance(this);

    datestr = getIntent().getStringExtra("date");

    TextView heading = (TextView) findViewById(R.id.dateheading);
    heading.setText(datestr);

    mRecyclerView = (RecyclerView) findViewById(R.id.expenselist);

    mLayoutManager = new LinearLayoutManager(this);
    mRecyclerView.setLayoutManager(mLayoutManager);

    List<Expense> explist = fetchExpenses();
    List<String> expstr = new ArrayList<String>();

    for (int i = 0; i < explist.size(); i++) {
      expstr.add(explist.get(i)._place + ": " + explist.get(i)._cost);
    }

    mAdapter = new ExpenseAdapter(expstr, this);
    mRecyclerView.setAdapter(mAdapter);
  }
 private void setupRvMovies() {
   preloadLayoutManager = new PreloadLayoutManager(getActivity());
   adapter = new TrendingShowsAdapter(this, getActivity());
   rvMovies.setLayoutManager(preloadLayoutManager);
   rvMovies.setAdapter(adapter);
   rvMovies.addOnScrollListener(recyclerViewOnScrollListener);
 }
Beispiel #16
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   AppController.getController().getBus().register(this);
   manager = new GridLayoutManager(this, getResources().getInteger(R.integer.num_row));
   recycler.setItemAnimator(new DefaultItemAnimator());
   recycler.setHasFixedSize(true);
   recycler.setLayoutManager(manager);
   mDrawerLayout.setStatusBarBackgroundColor(
       AppHelper.getPrimaryDarkColor(AppHelper.getPrimaryColor(this)));
   navigationView.setItemIconTintList(ColorStateList.valueOf(AppHelper.getAccentColor(this)));
   if (AppHelper.isDarkTheme(this)) {
     navigationView.setItemTextColor(ColorStateList.valueOf(AppHelper.getAccentColor(this)));
   }
   adapter = new AppsAdapter(this, new ArrayList<AppsModel>());
   recycler.setAdapter(adapter);
   mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
   if (navigationView != null) {
     setupDrawerContent(navigationView);
   }
   getLoaderManager().restartLoader(0, null, this);
   productsList.addAll(Arrays.asList(getResources().getStringArray(R.array.in_app_billing)));
   mHelper = new IabHelper(this, getString(R.string.base64));
   mHelper.startSetup(mPurchaseFinishedListener);
   showWhatsNew();
   countBackup();
 }
  private void initRecyclerViewCard() {

    mRecyclerView = (RecyclerView) v.findViewById(R.id.my_recycler_view_cardView);
    mLayoutManager = new LinearLayoutManager(getActivity().getApplicationContext());
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setLayoutManager(mLayoutManager);
    mAdapter = new MyRecyclerViewAdapterCardView(myDataset);
    mRecyclerView.setAdapter(mAdapter);

    // Code to Add an item with default animation
    // ((MyRecyclerViewAdapter) mAdapter).addItem(obj, index);

    // Code to remove an item with default animation
    // ((MyRecyclerViewAdapter) mAdapter).deleteItem(index);
    ((MyRecyclerViewAdapterCardView) mAdapter)
        .setOnItemClickListener(
            new MyRecyclerViewAdapterCardView.MyClickListener() {
              @Override
              public void onItemClick(int position, View v) {
                ArrayList<String> temp = mLstOrders.get(position);
                intent.putStringArrayListExtra("dish", temp);
                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(intent);
              }
            });
  }
Beispiel #18
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View layout = inflater.inflate(R.layout.fragment_navigation_drawer, container, false);
    recyclerView = (RecyclerView) layout.findViewById(R.id.drawerList);
    adapter = new NavigationDrawerAdapter(getActivity(), ((MainActivity) getActivity()).getData());
    recyclerView.setHasFixedSize(true);
    recyclerView.setAdapter(adapter);
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    recyclerView.addOnItemTouchListener(
        new RecyclerTouchListener(
            getActivity(),
            recyclerView,
            new ClickListener() {

              @Override
              public void onClick(View view, final int position) {
                if ((position + 1) > ManagerFragmentId.playlistFragment()
                    && (position + 1) < ManagerFragmentId.settingFragment()) return;
                if ((position + 1) != ManagerFragmentId.settingFragment()) {
                  adapter.selectPosition(position);
                }
                drawerListener.onDrawerItemSelected(view, position);
                mDrawerLayout.closeDrawer(containerView);
              }

              @Override
              public void onLongClick(View view, int position) {}
            }));
    return layout;
  }
  @Override
  protected void setupLayout() {
    mLayoutManager = new GridLayoutManager(getActivity(), 2);
    mAdapter = new ProductListAdapter(getActivity(), null);

    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.addItemDecoration(new MarginDecoration(getActivity()));
    mRecyclerView.setLayoutManager(mLayoutManager);
    mRecyclerView.setAdapter(mAdapter);
    mRecyclerView.addOnItemTouchListener(
        new RecyclerItemClickListener(
            getActivity(),
            new RecyclerItemClickListener.OnItemClickListener() {
              @Override
              public void onItemClick(View view, int position) {
                manager.currentProductDetailed = manager.productList.get(position);
                ((BaseActivity_NavDrawer) getActivity())
                    .navigator.openNewActivity(getActivity(), new ProductDetailActivity());
                Log.d("CLICK", "Clicked on item" + position);
              }
            }));

    mSwipeRefreshLayout.setColorSchemeResources(R.color.app_primary, R.color.signal_green);
    mSwipeRefreshLayout.setOnRefreshListener(
        new SwipeRefreshLayout.OnRefreshListener() {
          @Override
          public void onRefresh() {
            makeAPICall();
          }
        });

    makeAPICall();
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_estadisticas, container, false);

    RecyclerView rvHerramientas = (RecyclerView) rootView.findViewById(R.id.recycler_estadisticas);
    List<ItemEstadistica> estadisticas = new ArrayList<ItemEstadistica>();
    estadisticas.add(
        new ItemEstadistica(
            "Estadistica marcas",
            "ic_estadisticas",
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                ((ActivityPrincipal) getActivity()).setFlujo(new FlujoTemporizador());
                ((ActivityPrincipal) getActivity()).finish();
                ((ActivityPrincipal) getActivity())
                    .startActivity(
                        new Intent(
                            ((ActivityPrincipal) getActivity()), ActivityEstadisticaMarcas.class));
              }
            }));

    // Set adapter.
    EstadisticaAdapter adapter =
        new EstadisticaAdapter(estadisticas, (ActivityPrincipal) getActivity(), getContext());
    rvHerramientas.setAdapter(adapter);
    rvHerramientas.setLayoutManager(new LinearLayoutManager(rootView.getContext()));

    return rootView;
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tarot_feedback);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    final ActionBar ab = getSupportActionBar();
    ab.setDisplayHomeAsUpEnabled(false);

    FloatingActionButton fablogin = (FloatingActionButton) findViewById(R.id.fab_login);
    fablogin.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            if (TextUtils.isEmpty(getUsername())) {
              facebookLogin();
            } else {
              addFeedback(getUsername());
            }
          }
        });
    RecyclerView rv = (RecyclerView) findViewById(R.id.recyclerview);
    rv.setHasFixedSize(true);
    LinearLayoutManager llm = new LinearLayoutManager(this);
    llm.setOrientation(LinearLayoutManager.VERTICAL);
    rv.setLayoutManager(llm);
    updateList();
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_programme_list, container, false);
    FragmentActivity context = getActivity();

    rv = (RecyclerView) view.findViewById(R.id.rec_view_prog);
    LinearLayoutManager llm = new LinearLayoutManager(context);
    rv.setLayoutManager(llm);

    // Init programme list adapter
    programmes = Programme.listAll(Programme.class);
    programmeAdapter = new ProgrammeAdapter(programmes);

    // Set adapter to page view
    rv.setAdapter(programmeAdapter);

    programmeAdapter.SetOnItemClickListener(
        new ProgrammeAdapter.OnItemClickListener() {
          public void onItemClick(View v, int position) {

            // Load programme detail fragment on item click

            Programme selectedProgramme = programmes.get(position);
            mListener.onProgrammeSelected(selectedProgramme.getId());
          }
        });

    return view;
  }
Beispiel #23
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    activateToolbar();

    mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));

    flickrRecyclerViewAdapter =
        new FlickrRecyclerViewAdapter(MainActivity.this, new ArrayList<Photo>());
    mRecyclerView.setAdapter(flickrRecyclerViewAdapter);
    mRecyclerView.addOnItemTouchListener(
        new RecyclerItemClickListener(
            this,
            mRecyclerView,
            new RecyclerItemClickListener.OnItemClickListener() {
              @Override
              public void onItemClick(View view, int position) {
                Toast.makeText(MainActivity.this, "Normal tap", Toast.LENGTH_SHORT).show();
              }

              @Override
              public void onItemLongClick(View view, int position) {
                //                Toast.makeText(MainActivity.this, "Long tap",
                // Toast.LENGTH_SHORT).show();
                Intent intent = new Intent(MainActivity.this, ViewPhotoDetailsActivity.class);

                // additional data to be sent to and accessed by next activity
                intent.putExtra(PHOTO_TRANSFER, flickrRecyclerViewAdapter.getPhoto(position));
                startActivity(intent);
              }
            }));
  }
  private void initRecyclerView() {

    Toolbar mActionBarToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mActionBarToolbar);
    getSupportActionBar().setTitle("Grid view");

    recyclerView = (RecyclerView) findViewById(R.id.recycler);
    recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
    adapter = new RecyclerViewAdapter(items);
    adapter.setOnItemClickListener(this);
    recyclerView.setAdapter(adapter);

    btn_grid = (Button) findViewById(R.id.btn_grid);
    btn_grid.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            if (!isSingleGrid) {
              recyclerView.setLayoutManager(new GridLayoutManager(GridViewActivity.this, 1));
              adapter.notifyDataSetChanged();
              isSingleGrid = true;
              btn_grid.setText("MULTI GRID");
            } else {
              recyclerView.setLayoutManager(new GridLayoutManager(GridViewActivity.this, 2));
              adapter.notifyDataSetChanged();
              isSingleGrid = false;
              btn_grid.setText("SINGLE GRID");
            }
          }
        });
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // 初始化
    initDatas();
    initViews();

    mAdapter = new StaggeredAdapter(this, mDatas);
    mRecyclerView.setAdapter(mAdapter);

    // 设置RecyclerView的布局管理
    mRecyclerView.setLayoutManager(
        new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL));
    mAdapter.setOnItemClickListener(
        new SimpleAdapter.OnItemClickListener() {
          @Override
          public void onItemClick(View view, int position) {
            //                mAdapter.deleteData(position);
          }

          @Override
          public void onItemLongClick(View view, int position) {
            mAdapter.deleteData(position);
          }
        });
  }
Beispiel #26
0
  private void initiateView() {
    LayoutInflater.from(mContext).inflate((R.layout.search_view), this, true);

    mSearchLayout = findViewById(R.id.search_layout);
    mCardView = (CardView) mSearchLayout.findViewById(R.id.cardView);

    LinearLayoutManager layoutManager =
        new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false);
    mSuggestionsRecyclerView = (RecyclerView) mSearchLayout.findViewById(R.id.recyclerView);
    mSuggestionsRecyclerView.setLayoutManager(layoutManager);
    mSuggestionsRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mSuggestionsRecyclerView.setVisibility(GONE);

    mSearchEditText = (EditText) mSearchLayout.findViewById(R.id.editText_input);
    mBackImageView = (ImageView) mSearchLayout.findViewById(R.id.imageView_arrow_back);
    mVoiceImageView = (ImageView) mSearchLayout.findViewById(R.id.imageView_mic);
    mEmptyImageView = (ImageView) mSearchLayout.findViewById(R.id.imageView_clear); // CLEAR
    mTintView = mSearchLayout.findViewById(R.id.view_transparent);
    mSeparatorView = mSearchLayout.findViewById(R.id.view_separator);

    mSearchEditText.setOnClickListener(mOnClickListener);
    mBackImageView.setOnClickListener(mOnClickListener);
    mVoiceImageView.setOnClickListener(mOnClickListener);
    mEmptyImageView.setOnClickListener(mOnClickListener);
    mTintView.setOnClickListener(mOnClickListener);
    mSeparatorView.setVisibility(GONE);

    showVoice(true);
    initSearchView();
  }
Beispiel #27
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup viewGroup, Bundle savedInstanceState) {

    View root = inflater.inflate(R.layout.fragment_log, viewGroup, false);
    RecyclerView recycler = (RecyclerView) root.findViewById(R.id.cardList);
    recycler.setAdapter(mAdapter);
    recycler.setLayoutManager(new LinearLayoutManager(getActivity()));

    initFloatingActionButton();

    // Pull-to-refresh
    SwipeRefreshLayout swipeRefreshLayout =
        (SwipeRefreshLayout) root.findViewById(R.id.refresh_layout);
    swipeRefreshLayout.setColorSchemeColors(
        ContextCompat.getColor(getActivity(), R.color.colorPrimary),
        ContextCompat.getColor(getActivity(), R.color.colorAccent),
        ContextCompat.getColor(getActivity(), R.color.colorPrimaryDark));
    swipeRefreshLayout.setOnRefreshListener(
        new SwipeRefreshLayout.OnRefreshListener() {
          @Override
          public void onRefresh() {
            mPresenter.loadLog(true);
          }
        });

    return root;
  }
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    recyclerView = (RecyclerView) view.findViewById(R.id.list_recyclerViewFragment_content);
    GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(), 4);
    gridLayoutManager.setSpanSizeLookup(
        new GridLayoutManager.SpanSizeLookup() {
          @Override
          public int getSpanSize(int position) {
            RecyclerView.Adapter adapter = recyclerView.getAdapter();
            if (adapter == null || !(adapter instanceof AssemblyRecyclerAdapter)) {
              return 1;
            }
            return ((AssemblyRecyclerAdapter) adapter).getSpanSize(position);
          }
        });
    recyclerView.setLayoutManager(gridLayoutManager);

    if (adapter != null) {
      recyclerView.setAdapter(adapter);
    } else {
      loadAppList();
    }
  }
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.fragment_restaurant, container, false);

    RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.restaurant_fragment_recycler);
    recyclerView.setHasFixedSize(true);

    recyclerView.setLayoutManager(mStaggeredGridLayoutManager);

    final RuAdapter ruAdapter = new RuAdapter(getActivity());
    recyclerView.setAdapter(ruAdapter);

    final SwipeRefreshLayout swipeRefreshLayout =
        (SwipeRefreshLayout) view.findViewById(R.id.restaurant_fragment_swipe_layout);
    swipeRefreshLayout.setOnRefreshListener(
        new SwipeRefreshLayout.OnRefreshListener() {
          @Override
          public void onRefresh() {
            Log.d(AppTags.UFRGS_MOBILE, "RU Refresh");
            ruAdapter.updateAdapter();
            swipeRefreshLayout.setRefreshing(false);
          }
        });

    return view;
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // init async handler
    asyncQuery = new MyAsyncQueryHandler(getContentResolver());

    setContentView(R.layout.activity_data_viewer);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            DialogFragment newFragment = new DataEntryFragment();
            newFragment.show(getFragmentManager(), "dataentry");
          }
        });

    RecyclerView dataViewer = (RecyclerView) findViewById(R.id.viewer);
    LinearLayoutManager llm = new LinearLayoutManager(this);
    dataViewer.setLayoutManager(llm);
    mAdapter = new DataViewerAdapter();
    dataViewer.setAdapter(mAdapter);

    // Setup the loader
    getLoaderManager().initLoader(DATA_LOADER_ID, null, this);

    setUpTempDataDisplay();
    setUpTempDataUpdate_Del();
  }