add cancel right drawable to the feed input text in the add feed activity to clear text
This commit is contained in:
parent
f018989547
commit
54cf68760f
@ -1,5 +1,6 @@
|
||||
package com.readrops.app.activities;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.arch.lifecycle.ViewModelProviders;
|
||||
import android.content.Intent;
|
||||
import android.support.annotation.NonNull;
|
||||
@ -12,8 +13,10 @@ import android.support.v7.widget.helper.ItemTouchHelper;
|
||||
import android.util.Log;
|
||||
import android.util.Patterns;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
@ -55,6 +58,7 @@ public class AddFeedActivity extends AppCompatActivity implements View.OnClickLi
|
||||
private AddFeedsViewModel viewModel;
|
||||
private ArrayList<Feed> feedsToUpdate;
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -73,6 +77,19 @@ public class AddFeedActivity extends AppCompatActivity implements View.OnClickLi
|
||||
validate.setOnClickListener(this);
|
||||
validate.setEnabled(false);
|
||||
|
||||
feedInput.setOnTouchListener((v, event) -> {
|
||||
final int DRAWABLE_RIGHT = 2;
|
||||
|
||||
if(event.getAction() == MotionEvent.ACTION_UP) {
|
||||
if(event.getRawX() >= (feedInput.getRight() - feedInput.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) {
|
||||
feedInput.setText("");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
viewModel = ViewModelProviders.of(this).get(AddFeedsViewModel.class);
|
||||
|
||||
parseItemsAdapter = new ItemAdapter<>();
|
||||
|
5
app/src/main/res/drawable/ic_cancel_grey.xml
Normal file
5
app/src/main/res/drawable/ic_cancel_grey.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<vector android:height="24dp" android:tint="#727272"
|
||||
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M12,2C6.47,2 2,6.47 2,12s4.47,10 10,10 10,-4.47 10,-10S17.53,2 12,2zM17,15.59L15.59,17 12,13.41 8.41,17 7,15.59 10.59,12 7,8.41 8.41,7 12,10.59 15.59,7 17,8.41 13.41,12 17,15.59z"/>
|
||||
</vector>
|
@ -33,11 +33,11 @@
|
||||
android:id="@+id/add_feed_text_input"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/feed_url" />
|
||||
android:hint="@string/feed_url"
|
||||
android:drawableEnd="@drawable/ic_cancel_grey"/>
|
||||
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/add_feed_load"
|
||||
style="@style/GenericButton"
|
||||
|
Loading…
x
Reference in New Issue
Block a user