Java Code Examples for android.support.v7.widget.LinearLayoutManager#setOrientation()

The following examples show how to use android.support.v7.widget.LinearLayoutManager#setOrientation() . 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: MemberTopicFragment.java    From V2EX with GNU General Public License v3.0 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                         @Nullable Bundle savedInstanceState) {
    if (savedView !=null){
        return savedView;
    }
    savedView = inflater.inflate(R.layout.frag_member_topic, container, false);
    ButterKnife.bind(this, savedView);

    mRecyclerViewAdapter = new TopicRecyclerViewAdapter(getContext(), mTopics);
    mRecyclerViewAdapter.setBottomPadding(BarUtils.getNavBarHeight());
    mRecyclerViewAdapter.setIsSimpleView(true);
    LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mRvTopics.setLayoutManager(layoutManager);
    mRvTopics.setNestedScrollingEnabled(false);
    mRvTopics.setAdapter(mRecyclerViewAdapter);

    mSwipeRefreshLayout.setOnRefreshListener(this::onRefresh);
    mSwipeRefreshLayout.setRefreshing(true);
    setSwipeRefreshTheme(mSwipeRefreshLayout);
    onRefresh();
    return savedView;
}
 
Example 2
Source File: FolderManagerFragment.java    From MarkdownEditors with Apache License 2.0 6 votes vote down vote up
@Override
    public void onCreateAfter(Bundle savedInstanceState) {
        super.onCreateAfter(savedInstanceState);
        initActionMode();
        //初始化Presenter
        mPresenter = new FolderManagerPresenter(files);
        mPresenter.attachView(this);


        //初始化recycleView
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext);
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        mfileList.setLayoutManager(linearLayoutManager);
        mfileList.setAdapter(mAdapter = new FileListAdapter(mContext, files));
//        mfileList.addItemDecoration(new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL_LIST));
        mfileList.setItemAnimator(new DefaultItemAnimator());
        mfileList.setLongClickable(true);
        mAdapter.setOnItemClickLitener(this);
        //如果是ListView 多选可以用MultiChoiceModeListener会方便很多
    }
 
Example 3
Source File: ThemeActivity.java    From AndroidDemo with MIT License 6 votes vote down vote up
private void init(){
    for (int i = 0 ;i < themeType.length;i++){
        ThemeInfo info = new ThemeInfo();
        info.setName(themeType[i]);
        info.setColor(colors[i]);
        info.setSelect((selectTheme == i) ? true : false);
        if (i == themeType.length-1){
            info.setBackground(R.color.nightBg);
        }else {
            info.setBackground(R.color.colorWhite);
        }
        themeInfoList.add(info);
    }
    recyclerView = (RecyclerView)findViewById(R.id.theme_rv);
    adapter = new ThemeAdapter();
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
    linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    recyclerView.setLayoutManager(linearLayoutManager);
    recyclerView.setAdapter(adapter);

}
 
Example 4
Source File: MainFragment.java    From monolog-android with MIT License 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    mGuessUsers = new ArrayList<>();
    View v = inflater.inflate(R.layout.fragment_main, container, false);

    //recycler view
    mRecyclerView = (RecyclerView) v.findViewById(R.id.list_gusses);
    mLayoutManager = new LinearLayoutManager(getActivity());
    mLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
    mRecyclerView.setLayoutManager(mLayoutManager);
    return v;
}
 
Example 5
Source File: RecordsAdapter.java    From UPMiss with GNU General Public License v3.0 5 votes vote down vote up
public RecordsAdapter(RecyclerView view, View nullView, AdapterSelectCallback callback) {
    mDataSet = new ArrayList<RecordViewModel>();
    mRecycler = view;
    mNullView = nullView;
    mCallback = callback;
    mPresenter = new RecordsPresenter(this);

    LinearLayoutManager layoutManager = new LinearLayoutManager(view.getContext());
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mRecycler.setLayoutManager(layoutManager);
    mRecycler.setAdapter(this);
}
 
Example 6
Source File: ContactRecordsAdapter.java    From UPMiss with GNU General Public License v3.0 5 votes vote down vote up
public ContactRecordsAdapter(UUID contactId, RecyclerView view, View nullView, AdapterSelectCallback callback) {
    mDataSet = new ArrayList<RecordViewModel>();
    mRecycler = view;
    mNullView = nullView;
    mCallback = callback;
    mPresenter = new ContactRecordsPresenter(contactId, this);

    LinearLayoutManager layoutManager = new LinearLayoutManager(view.getContext());
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mRecycler.setLayoutManager(layoutManager);
    mRecycler.setAdapter(this);
}
 
Example 7
Source File: SevenActivity.java    From YCBanner with Apache License 2.0 5 votes vote down vote up
private void initRecyclerView4() {
    LinearLayoutManager manager = new LinearLayoutManager(this);
    manager.setOrientation(LinearLayoutManager.HORIZONTAL);
    mRecyclerView4.setLayoutManager(manager);
    ScrollSnapHelper snapHelper = new ScrollSnapHelper();
    snapHelper.attachToRecyclerView(mRecyclerView4);
    SnapAdapter adapter = new SnapAdapter(this);
    mRecyclerView4.setAdapter(adapter);
    adapter.addAll(getData());
}
 
Example 8
Source File: CollapsingToolbarLayout2Activity.java    From AndroidStudyDemo with GNU General Public License v2.0 5 votes vote down vote up
private void initData() {
    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    layoutManager.setOrientation(OrientationHelper.VERTICAL);
    // 设置布局管理器
    mContentRV.setLayoutManager(layoutManager);
    ArrayList dataList = new ArrayList<>(100);
    for (int i = 0; i < 100; i++) {
        dataList.add("DIY-ITEM:" + i);
    }
    RecyclerAdapter adapter = new RecyclerAdapter(dataList);
    mContentRV.setAdapter(adapter);
}
 
Example 9
Source File: MainActivity.java    From double-direction-adapter-endless with MIT License 5 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        rv = (RecyclerView) findViewById(R.id.recycler_view);
        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
        rv.setLayoutManager(layoutManager);
        rv.setHasFixedSize(true);
        ArrayList<String> strings = new ArrayList<>();
        strings.addAll(Arrays.asList(
                randomCheese(),
                randomCheese(),
                randomCheese(),
                randomCheese(),
                randomCheese(),
                randomCheese(),
                randomCheese(),
                randomCheese(),
                randomCheese(),
                randomCheese()));
        adapter = new SimpleStringAdapter(layoutManager, 30, strings);
        endlessRecyclerViewAdapter = new EndlessRecyclerViewAdapter(this, adapter, this);
        rv.setAdapter(endlessRecyclerViewAdapter);
//        rv.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST));
    }
 
Example 10
Source File: BottomSheetActivity.java    From MyBlogDemo with Apache License 2.0 5 votes vote down vote up
private void initSheet() {
    adapter = new MyAdapter<>();
    mSheet.setAdapter(adapter);

    LinearLayoutManager manager = new LinearLayoutManager(this);
    manager.setOrientation(LinearLayoutManager.VERTICAL);
    mSheet.setLayoutManager(manager);

    mContainer.registerCallback(new BottomSheet.Callbacks() {
        @TargetApi(Build.VERSION_CODES.LOLLIPOP)
        @Override
        public void onSheetDismissed() {
            super.onSheetDismissed();
            BottomSheetActivity.this.finishAfterTransition();
        }

        @Override
        public void onSheetPositionChanged(int sheetTop, boolean userInteracted) {
            super.onSheetPositionChanged(sheetTop, userInteracted);
        }

        @Override
        public void onSheetPositionScrolled(float percent) {
            super.onSheetPositionScrolled(percent);
            int padding = (int) (statusBarHeight * percent);
            if (currentPadding == 0) {
                currentPadding = padding;
            }
            int dy = padding - currentPadding;
            Log.i("TAG", "onSheetPositionScrolled: " + padding);
            tittle.setPadding(tittle.getPaddingLeft(), dy + tittle.getPaddingTop(), tittle.getPaddingRight(), tittle.getPaddingBottom());
            currentPadding = padding;
        }
    });

}
 
Example 11
Source File: MenuPopup.java    From Common with Apache License 2.0 5 votes vote down vote up
protected void initRecyclerList(View rootView, @IdRes int id, int orientation) {
    RecyclerView list = (RecyclerView) rootView.findViewById(id);
    LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);
    layoutManager.setOrientation(orientation);
    list.setLayoutManager(layoutManager);
    list.setAdapter(getAdapter());
}
 
Example 12
Source File: MainFragment.java    From android-network-security-config with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {


    PostAdapter.PostAdapterCallback mPostLoadingListener = new PostAdapter.PostAdapterCallback() {

        @Override
        public void onPostImageLoadingError(String error, Exception e) {
            mPresenter.onLoadPostImageError(error, e);
        }
    };
    mPostAdapter = new PostAdapter(getContext(), mPostLoadingListener);

    // Inflate the layout for this fragment
    View layout = inflater.inflate(R.layout.fragment_main, container, false);
    mProgressBar = (ProgressBar) layout.findViewById(R.id.progressBar);
    mLayout = (CoordinatorLayout) layout.findViewById(R.id.layout_coordinator);
    mPostList = (RecyclerView) layout.findViewById(R.id.post_list);
    mEmptyView = layout.findViewById(R.id.empty_view);

    LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mPostList.setLayoutManager(layoutManager);
    mPostList.setAdapter(mPostAdapter);

    layout.findViewById(R.id.load_posts).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onLoadPostsClick();
        }
    });

    return layout;
}
 
Example 13
Source File: FragmentDefinitionRefreshAndLoading.java    From Collection-Android with MIT License 5 votes vote down vote up
@Override
public void init() {

	LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
	linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
	mRecyclerView.setLayoutManager(linearLayoutManager);
	mRecyclerView.setPullRefreshEnabled(true);
	mRecyclerView.setLoadMoreEnabled(true);
	mRecyclerView.setRefreshAndLoadMoreListener(this);
	mRecyclerView.setRefreshView(new DefinitionAnimationRefreshHeaderView(getActivity()));
	mRecyclerView.setLoadMoreView(new DefinitionAnimationLoadMoreView(getActivity()));
}
 
Example 14
Source File: NetworkAPIFunction.java    From QPM with Apache License 2.0 4 votes vote down vote up
@Override
public void renderer(View layout) {
    initData();
    mRecyclerView = layout.findViewById(R.id.rv_network_api);
    mAdapter = new CommonRecyclerAdapter<Item>(mContext, mRecyclerView, mItems, R.layout.jm_gt_item_network_api) {

        @Override
        protected void onBind(CommonViewHolder viewHolder, View itemView, int position, int viewType, final Item data) {
            TextView timeView = itemView.findViewById(R.id.tv_time);
            LinearLayout titleLayout = itemView.findViewById(R.id.ll_title);
            TextView titleView = itemView.findViewById(R.id.tv_title);
            ImageView arrowView = itemView.findViewById(R.id.iv_arrow);
            LinearLayout detailLayout = itemView.findViewById(R.id.ll_detail);
            TextView sourceUrlView = itemView.findViewById(R.id.tv_source_url);
            TextView requestMethodView = itemView.findViewById(R.id.tv_request_method);
            TextView responseCodeView = itemView.findViewById(R.id.tv_response_code);
            TextView requestTimeView = itemView.findViewById(R.id.tv_request_time);
            TextView requestSizeView = itemView.findViewById(R.id.tv_request_size);
            TextView responseSizeView = itemView.findViewById(R.id.tv_response_size);
            TextView requestHeaderView = itemView.findViewById(R.id.tv_request_header);
            TextView requestContentView = itemView.findViewById(R.id.tv_request_content);
            TextView responseHeaderView = itemView.findViewById(R.id.tv_response_header);
            TextView responseContentView = itemView.findViewById(R.id.tv_response_content);

            timeView.setText(data.time);
            titleView.setText(data.path);
            if (data.isFold) {
                arrowView.setImageResource(R.drawable.jm_gt_unfold_arrow);
                detailLayout.setVisibility(View.GONE);
            } else {
                arrowView.setImageResource(R.drawable.jm_gt_fold_arrow);
                detailLayout.setVisibility(View.VISIBLE);
                sourceUrlView.setText(mContext.getString(R.string.jm_gt_source_url, data.networkInfo.originUrl));
                requestMethodView.setText(mContext.getString(R.string.jm_gt_request_method, data.networkInfo.method));
                responseCodeView.setText(mContext.getString(R.string.jm_gt_response_code, data.networkInfo.responseCode));
                requestTimeView.setText(mContext.getString(R.string.jm_gt_request_time, data.networkInfo.requestTime));
                requestSizeView.setText(mContext.getString(R.string.jm_gt_request_size, DecimalFormatUtil.divider(data.networkInfo.requestSize, 1024, 3)));
                responseSizeView.setText(mContext.getString(R.string.jm_gt_response_size, DecimalFormatUtil.divider(data.networkInfo.responseSize, 1024, 3)));
                requestHeaderView.setText(mContext.getString(R.string.jm_gt_request_header, data.networkInfo.requestHeader));
                requestContentView.setText(mContext.getString(R.string.jm_gt_request_content, data.networkInfo.requestContent));
                responseHeaderView.setText(mContext.getString(R.string.jm_gt_response_header, data.networkInfo.responseHeader));
                responseContentView.setText(mContext.getString(R.string.jm_gt_response_content, data.networkInfo.responseContent));
            }

            View.OnClickListener listener = new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    data.isFold = !data.isFold;
                    notifyDataSetChanged();
                }
            };
            timeView.setOnClickListener(listener);
            titleLayout.setOnClickListener(listener);
        }
    };
    LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mAdapter.setLayoutManager(layoutManager, 1, Color.parseColor("#DADADA"));
    mRecyclerView.setAdapter(mAdapter);
    mAdapter.setDatas(mItems);
}
 
Example 15
Source File: FragmentSearch.java    From uPods-android with Apache License 2.0 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ((IToolbarHolder) getActivity()).getToolbar().setVisibility(View.VISIBLE);

    //Init fragments views
    View view = inflater.inflate(R.layout.fragment_search_results, container, false);
    lnInternetError = (LinearLayout) view.findViewById(R.id.lnInternetError);
    pbLoadingSearch = (ProgressBar) view.findViewById(R.id.pbLoadingSearch);
    rvSearchResults = (RecyclerView) view.findViewById(R.id.rvSearchResults);
    tvSearchNoResults = (TextView) view.findViewById(R.id.tvSearchNoResults);
    tvStartTyping = (TextView) view.findViewById(R.id.tvSearchStart);
    smallPlayer = new SmallPlayer(view, getActivity());

    LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
    layoutManager.setOrientation(OrientationHelper.VERTICAL);

    //Toolbar
    MenuItem searchMenuItem = ((IToolbarHolder) getActivity()).getToolbar().getMenu().findItem(R.id.action_search);
    SearchView searchView = (SearchView) searchMenuItem.getActionView();
    searchView.setOnQueryTextListener(this);
    ((IToolbarHolder) getActivity()).getToolbar().setTitle(R.string.search_results);

    //Featured adapter
    mediaItemsAdapter = new MediaItemsAdapter(getActivity(), R.layout.card_media_item_horizontal, R.layout.media_item_title);
    if (getActivity() instanceof IFragmentsManager) {
        mediaItemsAdapter.setFragmentsManager((IFragmentsManager) getActivity());
    }

    //Featured recycle view
    rvSearchResults.setAdapter(mediaItemsAdapter);
    rvSearchResults.setLayoutManager(layoutManager);
    rvSearchResults.setVisibility(View.INVISIBLE);
    tvStartTyping.setVisibility(View.VISIBLE);
    pbLoadingSearch.setVisibility(View.GONE);

    FragmentSearch.isActive = true;
    if (lastQuery != null && !lastQuery.isEmpty()) {
        tvSearchNoResults.setVisibility(View.GONE);
        lnInternetError.setVisibility(View.GONE);
        tvStartTyping.setVisibility(View.GONE);
        loadSearchResults(lastQuery);
    }
    return view;
}
 
Example 16
Source File: MainActivity.java    From BS-Weather with Apache License 2.0 4 votes vote down vote up
@Override
public void initView() {
    setContentView(R.layout.acticity_main);

    Toolbar toolbar = (Toolbar)findViewById(R.id.tool_bar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null){
        actionBar.setDisplayShowTitleEnabled(false);
    }

    // 初始化各种控件

    weatherLayout = (ScrollView)findViewById(R.id.weather_layout);
    titleCity = (TextView)findViewById(R.id.title_city);
    forecastLayout = (LinearLayout)findViewById(R.id.forecast_layout);
    mainLayout = (LinearLayout) findViewById(R.id.main_layout);

    // weather_now
    degreeText = (TextView)findViewById(R.id.degree_text);
    weatherInfoText = (TextView)findViewById(R.id.weather_info_text);
    weaherNowLayout = (RelativeLayout)findViewById(R.id.weather_now_layout);
    updateTimeText = (TextView)findViewById(R.id.update_time_text);


    // weather_hour
    hourDegree = (TextView)findViewById(R.id.hour_degree);
    hourText = (TextView)findViewById(R.id.hour_text);
    hourTime = (TextView)findViewById(R.id.hout_time);

    recyclerView = (RecyclerView)findViewById(R.id.weather_hourly);
    hourAdapter = new HourAdapter(hourList);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
    linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
    recyclerView.setLayoutManager(linearLayoutManager);
    recyclerView.setAdapter(hourAdapter);



    // weather_aqi
    aqiText = (TextView)findViewById(R.id.aqi_text);
    pm25Text = (TextView)findViewById(R.id.pm25_text);
    coText = (TextView)findViewById(R.id.co_text);
    o3Text = (TextView)findViewById(R.id.o3_text);
    pm10Text = (TextView)findViewById(R.id.pm10_text);
    so2Text = (TextView)findViewById(R.id.so2_text);

    // weather_suggestion
    comfortText = (TextView)findViewById(R.id.comfort_text);
    carWashText = (TextView)findViewById(R.id.car_wash_text);
    sportText = (TextView)findViewById(R.id.sport_text);
    uvText = (TextView)findViewById(R.id.uv_text);
    clothesText = (TextView)findViewById(R.id.clothes_text);
    coldText = (TextView)findViewById(R.id.cold_text);
    comfortBtn = (Button)findViewById(R.id.comfort_button);
    carWashBtn = (Button)findViewById(R.id.car_wash_button);
    sportBtn = (Button)findViewById(R.id.sport_button);
    uvBtn = (Button)findViewById(R.id.uv_button);
    clothesBtn = (Button)findViewById(R.id.clothes_button);
    coldBtn = (Button)findViewById(R.id.cold_button);

    // LBS
    mlocationClient = new LocationClient(getApplicationContext());
    mlocationClient.registerLocationListener(new MyLocationListener());
    if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED){
        permissionList.add(Manifest.permission.ACCESS_FINE_LOCATION);
    }
    if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED){
        permissionList.add(Manifest.permission.READ_PHONE_STATE);
    }
    if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED){
        permissionList.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
    }
    if (!permissionList.isEmpty()){
        String[] permissions = permissionList.toArray(new String[permissionList.size()]);
        ActivityCompat.requestPermissions(MainActivity.this, permissions, 1);
    }

    swipeRefresh = (SwipeRefreshLayout)findViewById(R.id.swipe_refresh);
    swipeRefresh.setColorSchemeColors(getResources().getColor(R.color.colorAccent));


}
 
Example 17
Source File: CollectionActivity.java    From Jager with GNU General Public License v3.0 4 votes vote down vote up
private LinearLayoutManager getLayoutManager () {
	LinearLayoutManager layoutManager = new LinearLayoutManager (this);
	layoutManager.setOrientation (LinearLayoutManager.VERTICAL);
	return layoutManager;
}
 
Example 18
Source File: MainFragment.java    From AndroidSlidingUpPanel-foursquare-map-demo with Apache License 2.0 4 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mLocation = getArguments().getParcelable(ARG_LOCATION);
    if (mLocation == null) {
        mLocation = getLastKnownLocation(false);
    }

    mMapFragment = SupportMapFragment.newInstance();
    FragmentTransaction fragmentTransaction = getChildFragmentManager().beginTransaction();
    fragmentTransaction.add(R.id.mapContainer, mMapFragment, "map");
    fragmentTransaction.commit();

    ArrayList<String> testData = new ArrayList<String>(100);
    for (int i = 0; i < 100; i++) {
        testData.add("Item " + i);
    }
    // show white bg if there are not too many items
    // mWhiteSpaceView.setVisibility(View.VISIBLE);

    // ListView approach
    /*mListView.addHeaderView(mTransparentHeaderView);
    mListView.setAdapter(new ArrayAdapter<String>(getActivity(), R.layout.simple_list_item, testData));
    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            mSlidingUpPanelLayout.collapsePane();
        }
    });*/
    mHeaderAdapter = new HeaderAdapter(getActivity(), testData, this);
    mListView.setItemAnimator(null);
    final LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mListView.setLayoutManager(layoutManager);
    mListView.setAdapter(mHeaderAdapter);

    mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
            .addApi(LocationServices.API)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();

    setUpMapIfNeeded();
}
 
Example 19
Source File: RedditRecyclerView.java    From FriendlyDemo with Apache License 2.0 4 votes vote down vote up
private void setOrientation() {
    LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    setLayoutManager(layoutManager);
}
 
Example 20
Source File: InterpretationCommentsFragment.java    From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    mInterpretation = new Select()
            .from(Interpretation.class)
            .where(Condition.column(Interpretation$Table
                    .ID).is(getArguments().getLong(INTERPRETATION_ID)))
            .querySingle();
    UserAccount account = UserAccount
            .getCurrentUserAccountFromDb();
    mUser = new Select()
            .from(User.class)
            .where(Condition.column(User$Table
                    .UID).is(account.getUId()))
            .querySingle();

    ButterKnife.bind(this, view);

    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });

    mAdapter = new InterpretationCommentsAdapter(getActivity(),
            LayoutInflater.from(getActivity()), this, mUser);

    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
    linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    linearLayoutManager.setStackFromEnd(true);

    mRecyclerView.setLayoutManager(linearLayoutManager);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.setAdapter(mAdapter);

    Drawable buttonIcon = ContextCompat.getDrawable(
            getActivity(), R.mipmap.ic_comment_send);
    DrawableCompat.setTintList(buttonIcon, getResources()
            .getColorStateList(R.color.button_navy_blue_color_state_list));
    mAddNewComment.setImageDrawable(buttonIcon);

    handleAddNewCommentButton(EMPTY_FIELD);
}