Skip to content

Commit

Permalink
Uncommited changes from A4
Browse files Browse the repository at this point in the history
  • Loading branch information
RENEEGAILP committed Jun 14, 2021
2 parents 6f1fe28 + cb167ac commit 0f151c9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction)
int position = viewHolder.getLayoutPosition();
mItemList.remove( position );
mRecyclerViewAdapter.notifyItemRemoved( position );
Snackbar.make( mRecyclerView, "Link removed", Snackbar.LENGTH_LONG ).show();
}
} );
itemTouchHelper.attachToRecyclerView( mRecyclerView );
Expand All @@ -76,14 +77,21 @@ public void createLinkInputDialog() {
.setCancelable( false )
.setPositiveButton( getString( R.string.insert ),
(dialog, id) -> {
CardItem linkCard = new CardItem( mLinkNameEditTextView.getText().toString(),
mLinkURLEditTextView.getText().toString() );
if (linkCard.checkValidity()) {
mItemList.add( 0, linkCard );
mRecyclerViewAdapter.notifyItemInserted( 0 );
Snackbar.make( mRecyclerView, "Link added", Snackbar.LENGTH_LONG ).show();
} else {
Snackbar.make( mRecyclerView, "Link not added.\nPlease enter a valid URL(http://www.abc.com)", Snackbar.LENGTH_LONG ).show();
String linkName = mLinkNameEditTextView.getText().toString();
String linkURL = mLinkURLEditTextView.getText().toString();
if(linkName.isEmpty()) {
Snackbar.make( mRecyclerView, "Link not added.\nPlease enter a name", Snackbar.LENGTH_LONG ).show();
}
else
{
CardItem linkCard = new CardItem(linkName,linkURL);
if (linkCard.checkValidity()) {
mItemList.add( 0, linkCard );
mRecyclerViewAdapter.notifyItemInserted( 0 );
Snackbar.make( mRecyclerView, "Link added", Snackbar.LENGTH_LONG ).show();
} else {
Snackbar.make( mRecyclerView, "Link not added.\nPlease enter a valid URL(http://www.abc.com)", Snackbar.LENGTH_LONG ).show();
}
}
} )
.setNegativeButton( getString( R.string.cancel ),
Expand Down Expand Up @@ -118,8 +126,8 @@ private void buildRecyclerView() {

public void insertLink() {
mLinkNameEditTextView.getText().clear();
mLinkURLEditTextView.requestFocus();
mLinkURLEditTextView.getText().clear();
mLinkNameEditTextView.requestFocus();
mInsertLinkDialog.show();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:text="Enter name"
android:text="Name"
app:layout_constraintBottom_toTopOf="@+id/link_name_input"
app:layout_constraintEnd_toStartOf="@id/link_name_input"
app:layout_constraintHorizontal_weight="1"
Expand All @@ -33,7 +33,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:text="Enter URL"
android:text="URL"
app:layout_constraintBottom_toTopOf="@+id/link_url_input"
app:layout_constraintEnd_toStartOf="@id/link_url_input"
app:layout_constraintHorizontal_weight="1"
Expand All @@ -51,7 +51,9 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_weight="5"
app:layout_constraintStart_toEndOf="@id/link_name_text"
app:layout_constraintTop_toBottomOf="@id/new_link_text" />
app:layout_constraintTop_toBottomOf="@id/new_link_text"
android:focusable="true"
/>

<EditText
android:id="@+id/link_url_input"
Expand Down

0 comments on commit 0f151c9

Please sign in to comment.