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

The following examples show how to use android.support.v7.widget.LinearLayoutManager#setReverseLayout() . 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: ThreadFragment.java    From demo-firebase-android with The Unlicense 6 votes vote down vote up
@Override protected void postButterInit() {
    rvChat.setAdapter(adapter);
    layoutManager = new LinearLayoutManager(activity);
    layoutManager.setReverseLayout(false);
    rvChat.setLayoutManager(layoutManager);
    initMessageInput();
    rvChat.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
        if (bottom < oldBottom) {
            if (rvChat.getAdapter().getItemCount() > THRESHOLD_SCROLL) {
                rvChat.postDelayed(() -> rvChat.smoothScrollToPosition(
                        rvChat.getAdapter().getItemCount() - 1), 100);
            }
        }
    });
    srlRefresh.setOnRefreshListener(() -> {
        presenter.turnOffMessageListener();
        presenter.turnOnMessageListener(chatThread);
    });
}
 
Example 2
Source File: BangumiDetailsActivity.java    From HeroVideo-master with Apache License 2.0 6 votes vote down vote up
/**
 * 初始化选集recyclerView
 */
private void initSelectionRecycler()
{

    List<BangumiDetailsInfo.ResultBean.EpisodesBean> episodes = result.getEpisodes();

    mBangumiSelectionRecycler.setHasFixedSize(false);
    mBangumiSelectionRecycler.setNestedScrollingEnabled(false);
    LinearLayoutManager mLinearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
    mLinearLayoutManager.setReverseLayout(true);
    mBangumiSelectionRecycler.setLayoutManager(mLinearLayoutManager);
    BangumiDetailsSelectionAdapter mBangumiDetailsSelectionAdapter = new BangumiDetailsSelectionAdapter(mBangumiSelectionRecycler, episodes);
    mBangumiSelectionRecycler.setAdapter(mBangumiDetailsSelectionAdapter);
    mBangumiDetailsSelectionAdapter.notifyItemForeground(episodes.size() - 1);
    mBangumiSelectionRecycler.scrollToPosition(episodes.size() - 1);
    mBangumiDetailsSelectionAdapter.setOnItemClickListener((position, holder) -> {

        mBangumiDetailsSelectionAdapter.notifyItemForeground(holder.getLayoutPosition());
        VideoDetailsActivity.launch(BangumiDetailsActivity.this,
                episodes.get(position).getAv_id(), episodes.get(position).getCover());
        LogUtil.test(" getAv_id = "+ episodes.get(position).getAv_id());
    });
}
 
Example 3
Source File: PlayListFragment.java    From Android-AudioRecorder-App with Apache License 2.0 6 votes vote down vote up
private void initViews(View v) {
  emptyListLabel = v.findViewById(R.id.empty_list_label);
  mRecordingsListView = v.findViewById(R.id.recyclerView);
  mRecordingsListView.setHasFixedSize(true);
  LinearLayoutManager llm = new LinearLayoutManager(getActivity());
  llm.setOrientation(LinearLayoutManager.VERTICAL);

  //newest to oldest order (database stores from oldest to newest)
  llm.setReverseLayout(true);
  llm.setStackFromEnd(true);

  mRecordingsListView.setLayoutManager(llm);
  //mRecordingsListView.setItemAnimator(new DefaultItemAnimator());
  mRecordingsListView.setAdapter(mPlayListAdapter);
  playListPresenter.onViewInitialised();
}
 
Example 4
Source File: BangumiDetailsActivity.java    From HeroVideo-master with Apache License 2.0 6 votes vote down vote up
/**
 * 初始化选集recyclerView
 */
private void initSelectionRecycler()
{

    List<BangumiDetailsInfo.ResultBean.EpisodesBean> episodes = result.getEpisodes();

    mBangumiSelectionRecycler.setHasFixedSize(false);
    mBangumiSelectionRecycler.setNestedScrollingEnabled(false);
    LinearLayoutManager mLinearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
    mLinearLayoutManager.setReverseLayout(true);
    mBangumiSelectionRecycler.setLayoutManager(mLinearLayoutManager);
    BangumiDetailsSelectionAdapter mBangumiDetailsSelectionAdapter = new BangumiDetailsSelectionAdapter(mBangumiSelectionRecycler, episodes);
    mBangumiSelectionRecycler.setAdapter(mBangumiDetailsSelectionAdapter);
    mBangumiDetailsSelectionAdapter.notifyItemForeground(episodes.size() - 1);
    mBangumiSelectionRecycler.scrollToPosition(episodes.size() - 1);
    mBangumiDetailsSelectionAdapter.setOnItemClickListener((position, holder) -> {

        mBangumiDetailsSelectionAdapter.notifyItemForeground(holder.getLayoutPosition());
        VideoDetailsActivity.launch(BangumiDetailsActivity.this,
                episodes.get(position).getAv_id(), episodes.get(position).getCover());
        LogUtil.test(" getAv_id = "+ episodes.get(position).getAv_id());
    });
}
 
Example 5
Source File: FragmentChatMessageList.java    From Rumble with GNU General Public License v3.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    mView = inflater.inflate(R.layout.fragment_chatmessage_list, container, false);

    mRecyclerView = (RecyclerView) mView.findViewById(R.id.chat_message_list);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
    linearLayoutManager.setReverseLayout(true);
    mRecyclerView.setLayoutManager(linearLayoutManager);
    messageRecyclerAdapter = new ChatMessageRecyclerAdapter(getActivity(), this);
    mRecyclerView.setAdapter(messageRecyclerAdapter);

    compose = (EditText) mView.findViewById(R.id.chat_compose);

    sendBox = (FrameLayout) mView.findViewById(R.id.chat_send_box);
    sendBox.setOnClickListener(onClickSend);

    refreshChatMessages();
    EventBus.getDefault().register(this);

    return mView;
}
 
Example 6
Source File: FileViewerFragment.java    From SoundRecorder with GNU General Public License v3.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_file_viewer, container, false);

    RecyclerView mRecyclerView = (RecyclerView) v.findViewById(R.id.recyclerView);
    mRecyclerView.setHasFixedSize(true);
    LinearLayoutManager llm = new LinearLayoutManager(getActivity());
    llm.setOrientation(LinearLayoutManager.VERTICAL);

    //newest to oldest order (database stores from oldest to newest)
    llm.setReverseLayout(true);
    llm.setStackFromEnd(true);

    mRecyclerView.setLayoutManager(llm);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());

    mFileViewerAdapter = new FileViewerAdapter(getActivity(), llm);
    mRecyclerView.setAdapter(mFileViewerAdapter);

    return v;
}
 
Example 7
Source File: ThreadsListFragment.java    From demo-firebase-android with The Unlicense 5 votes vote down vote up
@Override protected void postButterInit() {
    LinearLayoutManager layoutManager = new LinearLayoutManager(activity);
    layoutManager.setReverseLayout(false);
    rvContacts.setLayoutManager(layoutManager);
    rvContacts.setAdapter(adapter);
    adapter.setClickListener((position, thread) -> {
        activity.changeFragmentWithThread(ChatControlActivity.ChatState.THREAD, thread);
    });
    srlRefresh.setOnRefreshListener(() -> {
        presenter.turnOffThreadsListener();
        presenter.turnOnThreadsListener();
    });
}
 
Example 8
Source File: TimelineActivity.java    From bridgefy-android-samples with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_timeline);
    ButterKnife.bind(this);

    // recover our username and set the maximum tweet size
    username = getIntent().getStringExtra(INTENT_USERNAME);
    txtMessage.setFilters(new InputFilter[] { new InputFilter.LengthFilter(138 - username.length()) });

    // Configure the Toolbar
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    gatewaySwitch.setChecked(true);

    // configure the recyclerview
    RecyclerView tweetsRecyclerView = findViewById(R.id.tweet_list);
    LinearLayoutManager mLinearLayoutManager = new LinearLayoutManager(this);
    mLinearLayoutManager.setReverseLayout(true);
    tweetsRecyclerView.setLayoutManager(mLinearLayoutManager);
    tweetsRecyclerView.setAdapter(tweetsAdapter);

    // Set the Bridgefy MessageListener
    Log.d(TAG, "Setting new State and Message Listeners");
    Bridgefy.setMessageListener(tweetManager = new TweetManager(username, this));

    // register the connected receiver
    registerReceiver(wifiReceiver,
            new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
}
 
Example 9
Source File: ChatActivity.java    From bridgefy-android-samples with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_chat);
    ButterKnife.bind(this);

    // recover our Peer object
    conversationName = getIntent().getStringExtra(INTENT_EXTRA_NAME);
    conversationId   = getIntent().getStringExtra(INTENT_EXTRA_UUID);

    // Configure the Toolbar
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    // Enable the Up button
    ActionBar ab = getSupportActionBar();
    if (ab != null) {
        ab.setTitle(conversationName);
        ab.setDisplayHomeAsUpEnabled(true);
    }

    // register the receiver to listen for incoming messages
    LocalBroadcastManager.getInstance(getBaseContext())
            .registerReceiver(new BroadcastReceiver() {
                @Override
                public void onReceive(Context context, Intent intent) {
                    Message message = new Message(intent.getStringExtra(MainActivity.INTENT_EXTRA_MSG));
                    message.setDeviceName(intent.getStringExtra(MainActivity.INTENT_EXTRA_NAME));
                    message.setDirection(Message.INCOMING_MESSAGE);
                    messagesAdapter.addMessage(message);
                }
            }, new IntentFilter(conversationId));

    // configure the recyclerview
    RecyclerView messagesRecyclerView = findViewById(R.id.message_list);
    LinearLayoutManager mLinearLayoutManager = new LinearLayoutManager(this);
    mLinearLayoutManager.setReverseLayout(true);
    messagesRecyclerView.setLayoutManager(mLinearLayoutManager);
    messagesRecyclerView.setAdapter(messagesAdapter);
}
 
Example 10
Source File: MainActivity.java    From Ucount with GNU General Public License v3.0 5 votes vote down vote up
public void setIoItemRecyclerView(Context context) {
    // 用于存储recyclerView的日期
    GlobalVariables.setmDate("");

    LinearLayoutManager layoutManager = new LinearLayoutManager(context);
    layoutManager.setStackFromEnd(true);    // 列表从底部开始展示,反转后从上方开始展示
    layoutManager.setReverseLayout(true);   // 列表反转

    ioItemRecyclerView.setLayoutManager(layoutManager);
    ioAdapter = new IOItemAdapter(ioItemList);
    ioItemRecyclerView.setAdapter(ioAdapter);
    ioTouchHelper.attachToRecyclerView(ioItemRecyclerView);
}
 
Example 11
Source File: MainActivity.java    From Simple-Blog-App with MIT License 5 votes vote down vote up
private void blogList() {
    mBlogList = findViewById(R.id.blog_list);
    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    layoutManager.setReverseLayout(true);
    layoutManager.setStackFromEnd(true);
    mBlogList.setHasFixedSize(true);
    mBlogList.setLayoutManager(layoutManager);
    floatingActionButton = findViewById(R.id.fab);
}
 
Example 12
Source File: DownloadsFragment.java    From OneTapVideoDownload with GNU General Public License v3.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    View rootView = inflater.inflate(R.layout.fragment_downloads, container, false);
    mRecyclerView = (RecyclerView) rootView.findViewById(R.id.downloadRecyclerView);
    ((SimpleItemAnimator) mRecyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
    LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
    layoutManager.setReverseLayout(true);
    layoutManager.setStackFromEnd(true);
    mRecyclerView.setLayoutManager(layoutManager);
    mRecyclerView.setHasFixedSize(true);

    mDownloadAdapter = new DownloadAdapter(getActivity());
    mRecyclerView.setAdapter(mDownloadAdapter);
    mEmptyView = rootView.findViewById(R.id.empty_view);
    FloatingActionButton usageInstructionButton = (FloatingActionButton)rootView.findViewById(R.id.usage_instruction_button);
    usageInstructionButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent usageInstructionIntent = new Intent(getActivity(), UsageInstruction.class);
            startActivity(usageInstructionIntent);
        }
    });

    return rootView;
}
 
Example 13
Source File: ChatFragment.java    From ChatApp with Apache License 2.0 4 votes vote down vote up
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
    final View view = inflater.inflate(R.layout.fragment_chat, container, false);

    String currentUserId = FirebaseAuth.getInstance().getCurrentUser().getUid();

    // Initialize Chat Database

    DatabaseReference chatDatabase = FirebaseDatabase.getInstance().getReference().child("Chat").child(currentUserId);
    chatDatabase.keepSynced(true); // For offline use

    // RecyclerView related

    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
    linearLayoutManager.setReverseLayout(true);
    linearLayoutManager.setStackFromEnd(true);

    RecyclerView recyclerView = view.findViewById(R.id.chat_recycler);
    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(linearLayoutManager);

    DividerItemDecoration mDividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(), linearLayoutManager.getOrientation());
    recyclerView.addItemDecoration(mDividerItemDecoration);

    // Initializing adapter

    FirebaseRecyclerOptions<Chat> options = new FirebaseRecyclerOptions.Builder<Chat>().setQuery(chatDatabase.orderByChild("timestamp"), Chat.class).build();

    adapter = new FirebaseRecyclerAdapter<Chat, ChatHolder>(options)
    {
        @Override
        public ChatHolder onCreateViewHolder(ViewGroup parent, int viewType)
        {
            View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.user, parent, false);

            return new ChatHolder(getActivity(), view, getContext());
        }

        @Override
        protected void onBindViewHolder(final ChatHolder holder, int position, final Chat model)
        {
            final String userid = getRef(position).getKey();

            holder.setHolder(userid, model.getMessage(), model.getTimestamp(), model.getSeen());
            holder.getView().setOnClickListener(new View.OnClickListener()
            {
                @Override
                public void onClick(View view)
                {
                    Intent chatIntent = new Intent(getContext(), ChatActivity.class);
                    chatIntent.putExtra("userid", userid);
                    startActivity(chatIntent);
                }
            });
        }

        @Override
        public void onDataChanged()
        {
            super.onDataChanged();

            TextView text = view.findViewById(R.id.f_chat_text);

            if(adapter.getItemCount() == 0)
            {
                text.setVisibility(View.VISIBLE);
            }
            else
            {
                text.setVisibility(View.GONE);
            }
        }
    };

    recyclerView.setAdapter(adapter);
    return view;
}
 
Example 14
Source File: FileActivity.java    From bridgefy-android-samples with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_file);
    ButterKnife.bind(this);

    // recover our Peer object
    conversationName = getIntent().getStringExtra(MainActivity.INTENT_EXTRA_NAME);
    conversationId   = getIntent().getStringExtra(MainActivity.INTENT_EXTRA_UUID);

    // Configure the Toolbar
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    // Enable the Up button
    ActionBar ab = getSupportActionBar();
    if (ab != null) {
        ab.setTitle(conversationName);
        ab.setDisplayHomeAsUpEnabled(true);
    }
    Log.i("C", "onCreate: conversation id is "+conversationId);

    // register the receiver to listen for incoming bridgefyFiles
    LocalBroadcastManager.getInstance(getBaseContext())
            .registerReceiver(new BroadcastReceiver() {
                @Override
                public void onReceive(Context context, Intent intent) {
                    Log.i(TAG, "onReceive: received message to adapter");
                    Message message = intent.getParcelableExtra(MainActivity.INTENT_EXTRA_MSG);
                    byte[] fileBytes = message.getData();
                    BridgefyFile bridgefyFile = new BridgefyFile((String)message.getContent().get("file"));
                    bridgefyFile.setData(fileBytes);
                    bridgefyFile.setDeviceName(intent.getStringExtra(MainActivity.INTENT_EXTRA_NAME));
                    bridgefyFile.setDirection(BridgefyFile.INCOMING_FILE);
                    messagesAdapter.addMessage(bridgefyFile);
                }
            }, new IntentFilter(conversationId));

    // configure the recyclerview
    RecyclerView messagesRecyclerView = findViewById(R.id.message_list);
    LinearLayoutManager mLinearLayoutManager = new LinearLayoutManager(this);
    mLinearLayoutManager.setReverseLayout(true);
    messagesRecyclerView.setLayoutManager(mLinearLayoutManager);
    messagesRecyclerView.setAdapter(messagesAdapter);
}
 
Example 15
Source File: FragmentStatusCommon.java    From TwrpBuilder with GNU General Public License v3.0 4 votes vote down vote up
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    view = inflater.inflate(R.layout.fragment_builds_common, container, false);

    RecyclerView lvBuilds = view.findViewById(R.id.lv_builds);
    Query query;
    if (filterQuery != null) {
        query = FirebaseDatabase.getInstance().getReference().child(reference).orderByChild(filterQuery).equalTo(equalTo);

    } else {
        query = FirebaseDatabase.getInstance()
                .getReference(reference);
    }
    query.keepSynced(true);
    FirebaseRecyclerOptions options = new FirebaseRecyclerOptions.Builder()
            .setQuery(query, Pbuild.class)
            .build();
    adapter = new FirebaseRecyclerAdapter<Pbuild, BuildsHolder>(options) {
        @NonNull
        @Override
        public BuildsHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
            View view = LayoutInflater.from(parent.getContext())
                    .inflate(R.layout.list_build_common, parent, false);
            if (filterQuery != null) {
                return new BuildsHolder(view, reference, true, getContext());
            } else {
                return new BuildsHolder(view, reference, false, getContext());
            }
        }

        @Override
        protected void onBindViewHolder(@NonNull BuildsHolder holder, int position, @NonNull Pbuild model) {
            holder.bind(
                    model.getEmail(),
                    model.getModel(),
                    model.getBoard(),
                    model.getDate(),
                    model.getBrand(),
                    model.getDeveloperEmail(),
                    model.getRejector(),
                    model.getNote(),
                    model.getUrl());
        }

        @Override
        public void onDataChanged() {
            super.onDataChanged();
            ProgressBar();
        }
    };
    ProgressBar();
    LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    layoutManager.setReverseLayout(true);
    layoutManager.setStackFromEnd(true);
    lvBuilds.setLayoutManager(layoutManager);
    lvBuilds.setAdapter(adapter);
    return view;

}