android.support.v7.widget.LinearLayoutManager Java Examples

The following examples show how to use android.support.v7.widget.LinearLayoutManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DevicesActivity.java    From bridgefy-android-samples with MIT License 7 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_devices);
    ButterKnife.bind(this);

    // initialize the DevicesAdapter and the RecyclerView
    devicesAdapter = new DevicesAdapter();
    devicesRecyclerView.setAdapter(devicesAdapter);
    devicesRecyclerView.setLayoutManager(new LinearLayoutManager(this));

    // check that we have Location permissions
    if (ContextCompat.checkSelfPermission(getApplicationContext(),
            Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
        initializeBridgefy();
    } else {
        ActivityCompat.requestPermissions(this,
                new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 0);
    }
}
 
Example #2
Source File: RelatedVideosFragment.java    From Loop with Apache License 2.0 6 votes vote down vote up
@Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        layoutManager = new LinearLayoutManager(getActivity());
        recyclerView.setLayoutManager(layoutManager);

        videosAdapter = new VideosAdapter();
        videosAdapter.setOnItemClickListener(this);
        videosAdapter.setOnReloadClickListener(this);

        recyclerView.setItemAnimator(new SlideInUpAnimator());
//        recyclerView.setItemAnimator(new DefaultItemAnimator());
        recyclerView.setAdapter(videosAdapter);

        // Pagination
        recyclerView.addOnScrollListener(recyclerViewOnScrollListener);

        Call findRelatedVideosCall = vimeoService.findRelatedVideos(videoId, currentPage, PAGE_SIZE);
        calls.add(findRelatedVideosCall);
        findRelatedVideosCall.enqueue(findRelatedVideosFirstFetchCallback);
    }
 
Example #3
Source File: SliceTestActivity.java    From incubator-weex-playground with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  try {
    WXSDKEngine.registerModule("searchEvent", SearchModule.class);
  } catch (WXException e) {
    e.printStackTrace();
  }
  setContentView(R.layout.activity_slice_test);
  mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
  mReportTextView = (TextView) findViewById(R.id.report_text);

  mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
  mRecyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
  mAdapter = new WXInstanceAdapter();
  mRecyclerView.setAdapter(mAdapter);
}
 
Example #4
Source File: ChatGroupsListFragment.java    From chat21-android-sdk with GNU Affero General Public License v3.0 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_chat_groups_list, container, false);

    // init RecyclerView
    recyclerViewChatGroups = view.findViewById(R.id.chat_groups_list);
    recyclerViewChatGroups.addItemDecoration(new ItemDecoration(getContext(),
            DividerItemDecoration.VERTICAL,
            getResources().getDrawable(R.drawable.decorator_activity_my_groups_list)));
    lmRvChatGroups = new LinearLayoutManager(getActivity());
    recyclerViewChatGroups.setLayoutManager(lmRvChatGroups);
    updateChatGroupsListAdapter(chatGroupsSynchronizer.getChatGroups());

    // no contacts layout
    noChatGroupsLayout = view.findViewById(R.id.layout_no_groups);
    toggleNoContactsLayoutVisibility(chatGroupsListAdapter.getItemCount());

    chatGroupsSynchronizer.addGroupsListener(this);
    chatGroupsSynchronizer.connect();

    return view;
}
 
Example #5
Source File: StartSnapHelper.java    From SimpleRecyclerView with Apache License 2.0 6 votes vote down vote up
private View getStartView(RecyclerView.LayoutManager layoutManager,
                          OrientationHelper helper) {
  if (!(layoutManager instanceof LinearLayoutManager)) {
    return super.findSnapView(layoutManager);
  }

  LinearLayoutManager linearLayoutManager = (LinearLayoutManager) layoutManager;

  int firstChild = linearLayoutManager.findFirstVisibleItemPosition();

  boolean isLastItem = linearLayoutManager.findLastCompletelyVisibleItemPosition() == layoutManager.getItemCount() - 1;

  if (firstChild == RecyclerView.NO_POSITION || isLastItem) {
    return null;
  }

  View child = layoutManager.findViewByPosition(firstChild);

  if (helper.getDecoratedEnd(child) >= helper.getDecoratedMeasurement(child) / 2
    && helper.getDecoratedEnd(child) > 0) {
    return child;
  } else {
    return layoutManager.findViewByPosition(firstChild + 1);
  }
}
 
Example #6
Source File: GravityDelegate.java    From Orin with GNU General Public License v3.0 6 votes vote down vote up
public View findSnapView(RecyclerView.LayoutManager layoutManager) {
    View snapView = null;
    if (layoutManager instanceof LinearLayoutManager) {
        switch (gravity) {
            case Gravity.START:
                snapView = findStartView(layoutManager, getHorizontalHelper(layoutManager));
                break;
            case Gravity.END:
                snapView = findEndView(layoutManager, getHorizontalHelper(layoutManager));
                break;
            case Gravity.TOP:
                snapView = findStartView(layoutManager, getVerticalHelper(layoutManager));
                break;
            case Gravity.BOTTOM:
                snapView = findEndView(layoutManager, getVerticalHelper(layoutManager));
                break;
        }
    }
    snapping = snapView != null;
    return snapView;
}
 
Example #7
Source File: AyahWordFragment.java    From Word-By-Word-Quran-Android with MIT License 6 votes vote down vote up
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {

    super.onViewCreated(view, savedInstanceState);

    //set Adapter with Animation
    //  ScaleInAnimationAdapter scaleInAnimationAdapter = new ScaleInAnimationAdapter(ayahWordAdapter);
    //  scaleInAnimationAdapter.setInterpolator(new OvershootInterpolator());
    mRecyclerView.setAdapter(ayahWordAdapter);
    mRecyclerView.setHasFixedSize(true);
    mLayoutManager = new LinearLayoutManager(getActivity());
    mRecyclerView.setLayoutManager(mLayoutManager);

    mRecyclerView.setVerticalScrollBarEnabled(true);


    //set headerview
    RecyclerViewHeader recyclerViewHeader = (RecyclerViewHeader) view.findViewById(R.id.header);
    TextView headerTextView = (TextView) recyclerViewHeader.findViewById(R.id.headerTextView);
    headerTextView.setText(getString(R.string.bismillah));
    recyclerViewHeader.attachTo(mRecyclerView, true);

}
 
Example #8
Source File: FavMetricsFragment.java    From hawkular-android-client with Apache License 2.0 6 votes vote down vote up
private void setUpMetrics() {

        Context context = this.getActivity();
        SQLStore<Metric> store = openStore(context);
        store.openSync();

        Collection<Metric> array = store.readAll();
        metrics = new ArrayList<>(array);
        recyclerView.setLayoutManager(new LinearLayoutManager(context));
        FavMetricsAdapter favMetricsAdapter = new FavMetricsAdapter(getActivity(), this, metrics);
        recyclerView.setAdapter(favMetricsAdapter);
        hideRefreshing();

        if(metrics.isEmpty()) {
            showMessage();
        } else {
            showList();
        }

        store.close();

    }
 
Example #9
Source File: RecyclerViewActivity.java    From ViewToImage with Apache License 2.0 6 votes vote down vote up
private void initHorizontal() {
    mHorizontalRecyclerView = (RecyclerView) findViewById(R.id.recyclerview_horizontal);

    // 创建一个线性布局管理器
    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
    // 设置布局管理器
    mHorizontalRecyclerView.setLayoutManager(layoutManager);

    // 创建数据集
    String[] dataset = new String[100];
    for (int i = 0; i < dataset.length; i++) {
        dataset[i] = "item" + i;
    }
    // 创建Adapter,并指定数据集
    MyRecyclerViewAdapter adapter = new MyRecyclerViewAdapter(dataset);
    // 设置Adapter
    mHorizontalRecyclerView.setAdapter(adapter);
}
 
Example #10
Source File: MenuFragment.java    From SwipeRecyclerView-master with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    mRecyclerView.addItemDecoration(new DefaultItemDecoration(ContextCompat.getColor(getContext(), R.color.divider_color)));

    mRecyclerView.setSwipeItemClickListener(mItemClickListener);
    mRecyclerView.setSwipeMenuCreator(mSwipeMenuCreator);
    mRecyclerView.setSwipeMenuItemClickListener(mMenuItemClickListener);

    MainAdapter menuAdapter = new MainAdapter(getContext());
    mRecyclerView.setAdapter(menuAdapter);
    List<String> dataList = new ArrayList<>();
    for (int i = 0; i < 30; i++) {
        dataList.add("我是第" + i + "个。");
    }
    menuAdapter.notifyDataSetChanged(dataList);
}
 
Example #11
Source File: ComplexDemoActivity.java    From OkSocket with MIT License 6 votes vote down vote up
private void initData() {
    mIPET.setEnabled(false);
    mPortET.setEnabled(false);

    LinearLayoutManager manager1 = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
    mSendList.setLayoutManager(manager1);
    mSendList.setAdapter(mSendLogAdapter);

    LinearLayoutManager manager2 = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
    mReceList.setLayoutManager(manager2);
    mReceList.setAdapter(mReceLogAdapter);

    mInfo = new ConnectionInfo("104.238.184.237", 8080);

    final Handler handler = new Handler(Looper.getMainLooper());
    OkSocketOptions.Builder builder = new OkSocketOptions.Builder();
    builder.setReconnectionManager(new NoneReconnect());
    builder.setCallbackThreadModeToken(new OkSocketOptions.ThreadModeToken() {
        @Override
        public void handleCallbackEvent(ActionDispatcher.ActionRunnable runnable) {
            handler.post(runnable);
        }
    });
    mManager = OkSocket.open(mInfo).option(builder.build());
}
 
Example #12
Source File: PageFragment.java    From funcodetuts with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_page, container, false);

    RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.main_recycler);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity().getBaseContext());
    recyclerView.setLayoutManager(linearLayoutManager);
    recyclerView.setHasFixedSize(true);

    List<String> list = new ArrayList<>();

    for (int i = 0; i < 10; i++) {
        list.add("Item " + i);
    }

    SimpleRecyclerAdapter adapter = new SimpleRecyclerAdapter(list);
    recyclerView.setAdapter(adapter);
    adapter.setOnItemTapListener(mListItemClickListener);
    return view;
}
 
Example #13
Source File: DefaultItemTouchHelperCallback.java    From TestChat with Apache License 2.0 6 votes vote down vote up
@Override
public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
    //判断当前是否是swipe方式:侧滑。
    if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) {
        //1.ItemView--ViewHolder; 2.侧滑条目的透明度程度关联谁?dX(delta增量,范围:当前条目-width~width)。
        RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
        float alpha = 1;
        if (layoutManager instanceof LinearLayoutManager) {
            int orientation = ((LinearLayoutManager) layoutManager).getOrientation();
            if (orientation == LinearLayoutManager.HORIZONTAL) {
                alpha = 1 - Math.abs(dY) / viewHolder.itemView.getHeight();
            } else if (orientation == LinearLayoutManager.VERTICAL) {
                alpha = 1 - Math.abs(dX) / viewHolder.itemView.getWidth();
            }
        }
        viewHolder.itemView.setAlpha(alpha);//1~0
    }
    super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
}
 
Example #14
Source File: EarthquakeListFragment.java    From Wrox-ProfessionalAndroid-4E with Apache License 2.0 6 votes vote down vote up
@Override
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
  super.onViewCreated(view, savedInstanceState);

  // Set the Recycler View adapter
  Context context = view.getContext();
  mRecyclerView.setLayoutManager(new LinearLayoutManager(context));
  mRecyclerView.setAdapter(mEarthquakeAdapter);

  // Setup the Swipe to Refresh view
  mSwipeToRefreshView.setOnRefreshListener(
    new SwipeRefreshLayout.OnRefreshListener() {
      @Override
      public void onRefresh() {
        updateEarthquakes();
      }
    });
}
 
Example #15
Source File: CollectionRecordActivity.java    From BaoKanAndroid with MIT License 6 votes vote down vote up
/**
 * 准备数据
 */
private void prepareData() {
    mCollectionRecordRecyclerView.setLayoutManager(new LinearLayoutManager(mContext));
    mAdapter = new CollectionRecordRecyclerViewAdapter(mContext);
    mCollectionRecordRecyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.HORIZONTAL));
    mCollectionRecordRecyclerView.setAdapter(mAdapter);
    mAdapter.setOnItemTapListener(new CollectionRecordRecyclerViewAdapter.OnItemTapListener() {
        @Override
        public void onItemTapListener(CollectionRecordBean collectionRecordBean) {
            if (collectionRecordBean.getTbname().equals("photo")) {
                PhotoDetailActivity.start(mContext, collectionRecordBean.getClassid(), collectionRecordBean.getId());
            } else {
                NewsDetailActivity.start(mContext, collectionRecordBean.getClassid(), collectionRecordBean.getId());
            }
        }
    });
}
 
Example #16
Source File: PostFrag.java    From httplite with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.frag_get,container,false);
    mRecyclerView = (RecyclerView) view.findViewById(R.id.file_list);
    mPathTv = (TextView) view.findViewById(R.id.tv_request_path);
    mAdapter = new FileAdapter(null,this);
    mRecyclerView.setAdapter(mAdapter);
    mRecyclerView.addItemDecoration(new RecycleViewDivider(getContext(), LinearLayoutManager.HORIZONTAL));
    mBackUpBtn = (Button) view.findViewById(R.id.btn_back_up);
    mBackUpBtn.setOnClickListener(this);
    if(basePath==null){
        File file = getActivity().getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS);
        if(file==null){
            file = getActivity().getCacheDir();
        }
        basePath = file.getAbsolutePath();
    }
    if(currentPath==null){
        currentPath = basePath;
    }
    mHttpLite = App.httpLite(getActivity());
    loadFiles(currentPath);
    return view;
}
 
Example #17
Source File: MessageSearchFragment.java    From talk-android with MIT License 6 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setAdapter(adapter);
    recyclerView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_UP && recyclerViewState == RecyclerView.SCROLL_STATE_IDLE) {
                getActivity().getSupportFragmentManager()
                        .beginTransaction()
                        .setCustomAnimations(R.anim.anim_fade_in, R.anim.anim_fade_out)
                        .remove(MessageSearchFragment.this)
                        .commit();
                if (listener != null) {
                    listener.onRemoveFragment();
                }
            }
            return false;
        }
    });
    recyclerView.addOnScrollListener(scrollListener);
}
 
Example #18
Source File: MainActivity.java    From styT with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(linearLayoutManager);

    recyclerView.getItemAnimator().setAddDuration(100);
    recyclerView.getItemAnimator().setRemoveDuration(100);
    recyclerView.getItemAnimator().setMoveDuration(200);
    recyclerView.getItemAnimator().setChangeDuration(100);

    myAdapter = new RecyclerAdapter(this);
    recyclerView.setAdapter(myAdapter);
    myAdapter.setOnScrollToListener(new OnScrollToListener() {

        @Override
        public void scrollTo(int position) {
            recyclerView.scrollToPosition(position);
        }
    });
    initDatas();
}
 
Example #19
Source File: SelectLocaleActivity.java    From alpha-wallet-android with MIT License 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_list);
    toolbar();
    setTitle(getString(R.string.settings_locale_lang));

    currentLocale = getIntent().getStringExtra(C.EXTRA_LOCALE);

    ArrayList<LocaleItem> localeItems = getIntent().getParcelableArrayListExtra(C.EXTRA_STATE);

    if (localeItems != null) {
        recyclerView = findViewById(R.id.list);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        adapter = new CustomAdapter(localeItems, currentLocale);
        recyclerView.setAdapter(adapter);
        recyclerView.addItemDecoration(new ListDivider(this));
    }
}
 
Example #20
Source File: WorkWorldAtListActivity.java    From imsdk-android with MIT License 6 votes vote down vote up
private void initAdapter() {
    workWorldAtListPresenter = new WorkWorldAtListManagerPresenter();
    workWorldAtListPresenter.setView(this);
    adapter = new WorkWorldAtListAdapter(this);
    isSelectAdapter = new WorkWorldAtListIsSelectAdapter(this);
    LinearLayoutManager manager = new LinearLayoutManager(this);
    manager.setOrientation(LinearLayoutManager.HORIZONTAL);
    work_world_isselect_rc.setLayoutManager(manager);
    work_world_isselect_rc.setAdapter(isSelectAdapter);
    adapter.setOnSelectChanage(list -> isSelectAdapter.setNewData(list));

    isSelectAdapter.setOnCancelLis(str -> {
        //操作树形列表
        adapter.setCancelInfo(str);
    });

    work_world_atlist_rc.setLayoutManager(new LinearLayoutManager(this));
    work_world_atlist_rc.addItemDecoration(new RecycleViewDivider(
            this, LinearLayoutManager.VERTICAL, 1, R.color.atom_ui_primary_color));
    work_world_atlist_rc.setAdapter(adapter);
}
 
Example #21
Source File: CountFragment.java    From AccountBook with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 初始化适配器
 */
private void initAdapter() {
    mRecyclerView.addItemDecoration(new HorizontalDividerItemDecoration.Builder(mContext)
            .color(R.color.colorDivide)
            .size(2)
            .build());
    mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext));
    mAdapter = new CountListAdapter(R.layout.item_count_list, new ArrayList<CountList>());
    mAdapter.setEmptyView(UiUtils.getEmptyView(mContext, mRecyclerView
            , UiUtils.getString(R.string.empty_count_data), R.mipmap.ic_pie_empty));
    mRecyclerView.setAdapter(mAdapter);
    mRecyclerView.addOnItemTouchListener(new OnSimpleClickListener(){
        @Override
        public void onItemClick(BaseQuickAdapter baseQuickAdapter, View view, int i) {
            CountList count = (CountList) baseQuickAdapter.getData().get(i);
            startActivity(new Intent(mContext, TypeCountDetailActivity.class)
                    .putExtra(AppConstants.EXTRA_TYPE_NAME, count.getTypeName())
                    .putExtra(AppConstants.EXTRA_TYPE, mCountType)
                    .putExtra(AppConstants.EXTRA_START_DATE, mStartDate)
                    .putExtra(AppConstants.EXTRA_END_DATE, mEndDate));
        }
    });
}
 
Example #22
Source File: ConversationFragment.java    From Android with MIT License 6 votes vote down vote up
/**
 * The view has been created
 *
 * @param savedInstanceState
 */
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    LogManager.getLogger().d(Tag, "onActivityCreated()");
    activity = getActivity();

    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(activity);
    recyclerFragmentChat.setLayoutManager(linearLayoutManager);
    chatFragmentAdapter = new ChatListAdapter(activity, recyclerFragmentChat);
    recyclerFragmentChat.setAdapter(chatFragmentAdapter);
    recyclerFragmentChat.addItemDecoration(new LineDecoration(activity));
    recyclerFragmentChat.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            chatFragmentAdapter.closeMenu();
        }
    });

    loadRooms();
    EventBus.getDefault().register(this);
}
 
Example #23
Source File: EightCollapsingActivity.java    From YCRefreshView with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_collapsing);
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    recyclerView = findViewById(R.id.recyclerView);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setAdapter(adapter = new PersonAdapter(this));
    adapter.setMore(R.layout.view_more, new OnLoadMoreListener() {
        @Override
        public void onLoadMore() {
            handler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    adapter.addAll(DataProvider.getPersonList(0));
                }
            }, 1000);
        }
    });
    adapter.addAll(DataProvider.getPersonList(0));
    BannerView rollPagerView = findViewById(R.id.rollPagerView);
    rollPagerView.setHintView(new ColorPointHintView(this, Color.YELLOW,Color.GRAY));
    rollPagerView.setAdapter(new BannerAdapter());
}
 
Example #24
Source File: MainActivity.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.shr_main);

    Toolbar appBar = (Toolbar) findViewById(R.id.app_bar);
    setSupportActionBar(appBar);

    ArrayList<ProductEntry> products = readProductsList();
    ImageRequester imageRequester = ImageRequester.getInstance(this);

    final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.product_list);
    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    adapter = new ProductAdapter(products, imageRequester);
    recyclerView.setAdapter(adapter);
}
 
Example #25
Source File: TabFragment.java    From Android-StickyNavLayout with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState)
{
    View view = inflater.inflate(R.layout.fragment_tab, container, false);
    mRecyclerView = (RecyclerView) view
            .findViewById(R.id.id_stickynavlayout_innerscrollview);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    // mTextView = (TextView) view.findViewById(R.id.id_info);
    // mTextView.setText(mTitle);
    for (int i = 0; i < 50; i++)
    {
        mDatas.add(mTitle + " -> " + i);
    }
    mRecyclerView.setAdapter(new CommonAdapter<String>(getActivity(), R.layout.item, mDatas)
    {
        @Override
        public void convert(ViewHolder holder, String o)
        {
            holder.setText(R.id.id_info, o);
        }
    });

    return view;

}
 
Example #26
Source File: PlacesSearchResultActivtity.java    From Place-Search-Service with MIT License 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.places_search_result_activity);
    EventBus.getDefault().register(this);
    mBack = findViewById(R.id.back);
    mList = findViewById(R.id.listview);
    mPrevious = findViewById(R.id.previous);
    mNext = findViewById(R.id.next);
    map = new HashMap<>();
    dialog = new ProgressDialog(this);
    dialog.setCancelable(false);
    dialog.setIndeterminate(true);
    dialog.setMessage("Fetching Next page");
    dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);

    mBack.setOnClickListener(this);
    mPrevious.setOnClickListener(this);
    mNext.setOnClickListener(this);
    obj = (PlacesSearchResultObj) getIntent().getSerializableExtra("data");
    searchUrl = getIntent().getStringExtra("url");
    if (obj.getResults() == null || obj.getResults().size() == 0) {
        getSupportFragmentManager().beginTransaction().replace(R.id.search_layout, new PlacesSearchNoneResultFragment()).commit();
        findViewById(R.id.btn_layout).setVisibility(View.GONE);
    }
    adapter = new PlacesSearchResultAdapter(this, obj.getResults());
    adapter.setListener(this);
    mList.setHasFixedSize(true);
    mList.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
    mList.setAdapter(adapter);
    map.put(currentIndex, obj);
    if (currentIndex == 0) mPrevious.setEnabled(false);
    if (TextUtils.isEmpty(map.get(currentIndex).getNext_page_token())){
        mNext.setEnabled(false);
    }else {
        mNext.setEnabled(true);
    }
}
 
Example #27
Source File: RecycleViewDivider.java    From SoloPi with Apache License 2.0 5 votes vote down vote up
@Override
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
    super.onDraw(c, parent, state);
    if (mOrientation == LinearLayoutManager.VERTICAL) {
        drawVertical(c, parent);
    } else {
        drawHorizontal(c, parent);
    }
}
 
Example #28
Source File: DividerItemDecoration.java    From droidddle with Apache License 2.0 5 votes vote down vote up
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
    super.getItemOffsets(outRect, view, parent, state);
    if (mDivider == null)
        return;
    if (parent.getChildPosition(view) < 1)
        return;

    if (getOrientation(parent) == LinearLayoutManager.VERTICAL)
        outRect.top = 0; //mDivider.getIntrinsicHeight()
    else
        outRect.left = mDivider.getIntrinsicWidth();
}
 
Example #29
Source File: WordDetailsAdapter.java    From allenglish with Apache License 2.0 5 votes vote down vote up
private void setRecyclerViewContent(RecyclerView recyclerView, RecyclerView.Adapter adapter) {
    recyclerView.setHasFixedSize(true);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(BaseApplication.getInstance()) {
        @Override
        public boolean canScrollVertically() {
            return false;
        }
    };
    recyclerView.setLayoutManager(linearLayoutManager);
    recyclerView.setAdapter(adapter);
}
 
Example #30
Source File: MainActivity.java    From MVideo with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mRecyclerView.setAdapter(new MainAdapter());
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
}