Search in sources :

Example 26 with DividerItemDecoration

use of androidx.recyclerview.widget.DividerItemDecoration in project RespawnIRC-Android by FranckRJ.

the class ManageSurveyOfTopicActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_managesurvey);
    initToolbar(R.id.toolbar_managesurvey);
    Button validateButton = findViewById(R.id.validate_button_managesurvey);
    Button addReplyButton = findViewById(R.id.addreply_button_managesurvey);
    listOfReplys = findViewById(R.id.reply_list_managesurvey);
    titleEdit = findViewById(R.id.title_edit_managesurvey);
    adapterForReplys = new SurveyReplysAdapter(this);
    validateButton.setOnClickListener(validateButtonClicked);
    addReplyButton.setOnClickListener(addReplyButtonClicked);
    listOfReplys.setNestedScrollingEnabled(false);
    listOfReplys.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
    listOfReplys.setLayoutManager(new LinearLayoutManager(this));
    listOfReplys.setAdapter(adapterForReplys);
    if (getIntent() != null && savedInstanceState == null) {
        String title = getIntent().getStringExtra(EXTRA_SURVEY_TITLE);
        ArrayList<String> replysList = getIntent().getStringArrayListExtra(EXTRA_SURVEY_REPLYS_LIST);
        if (!Utils.stringIsEmptyOrNull(title)) {
            titleEdit.setText(title);
        }
        if (replysList != null) {
            for (int i = 0; i < replysList.size(); ++i) {
                if (!Utils.stringIsEmptyOrNull(replysList.get(i))) {
                    adapterForReplys.addReply(replysList.get(i));
                }
            }
        }
    } else if (savedInstanceState != null) {
        ArrayList<String> newListOfReplysContent = savedInstanceState.getStringArrayList(SAVE_LIST_OF_REPLY_CONTENT);
        if (newListOfReplysContent != null) {
            adapterForReplys.setReplys(newListOfReplysContent);
        }
    }
    while (adapterForReplys.getItemCount() < 2) {
        adapterForReplys.addReply("");
    }
}
Also used : SurveyReplysAdapter(com.franckrj.respawnirc.jvcforum.jvcforumtools.SurveyReplysAdapter) Button(android.widget.Button) ArrayList(java.util.ArrayList) DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager)

Aggregations

DividerItemDecoration (androidx.recyclerview.widget.DividerItemDecoration)26 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)20 RecyclerView (androidx.recyclerview.widget.RecyclerView)15 View (android.view.View)12 TextView (android.widget.TextView)7 Button (android.widget.Button)6 Context (android.content.Context)5 ArrayList (java.util.ArrayList)5 Activity (android.app.Activity)4 Bundle (android.os.Bundle)4 ProgressBar (android.widget.ProgressBar)4 Nullable (androidx.annotation.Nullable)4 List (java.util.List)4 SuppressLint (android.annotation.SuppressLint)3 Log (android.util.Log)3 LayoutInflater (android.view.LayoutInflater)3 MenuItem (android.view.MenuItem)3 ViewGroup (android.view.ViewGroup)3 RelativeLayout (android.widget.RelativeLayout)3 NonNull (androidx.annotation.NonNull)3