recycler listsner ready
This commit is contained in:
parent
e4da9c7f99
commit
5ef12c7d83
6 changed files with 111 additions and 9 deletions
|
@ -15,6 +15,9 @@
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/Theme.AsgardiusS3Manager"
|
android:theme="@style/Theme.AsgardiusS3Manager"
|
||||||
tools:targetApi="31">
|
tools:targetApi="31">
|
||||||
|
<activity
|
||||||
|
android:name=".ObjectSelect"
|
||||||
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".list_item"
|
android:name=".list_item"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
|
|
@ -10,6 +10,7 @@ import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import asgardius.page.s3manager.BucketSelect;
|
||||||
|
|
||||||
public class Adapter extends RecyclerView.Adapter<Adapter.ViewHolder>{
|
public class Adapter extends RecyclerView.Adapter<Adapter.ViewHolder>{
|
||||||
ArrayList Img, Name;
|
ArrayList Img, Name;
|
||||||
|
@ -35,12 +36,6 @@ public class Adapter extends RecyclerView.Adapter<Adapter.ViewHolder>{
|
||||||
int res = (int) Img.get(position);
|
int res = (int) Img.get(position);
|
||||||
holder.images.setImageResource(res);
|
holder.images.setImageResource(res);
|
||||||
holder.text.setText((CharSequence) Name.get(position));
|
holder.text.setText((CharSequence) Name.get(position));
|
||||||
holder.text.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
System.out.println("Click on "+Integer.toString(position));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
|
|
|
@ -6,8 +6,10 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.amazonaws.auth.AWSCredentials;
|
import com.amazonaws.auth.AWSCredentials;
|
||||||
|
@ -27,13 +29,14 @@ public class BucketSelect extends AppCompatActivity {
|
||||||
ArrayList Name;
|
ArrayList Name;
|
||||||
ArrayList Img;
|
ArrayList Img;
|
||||||
RecyclerView recyclerView;
|
RecyclerView recyclerView;
|
||||||
|
String username, password, endpoint;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
String endpoint = getIntent().getStringExtra("endpoint");
|
endpoint = getIntent().getStringExtra("endpoint");
|
||||||
String username = getIntent().getStringExtra("username");
|
username = getIntent().getStringExtra("username");
|
||||||
String password = getIntent().getStringExtra("password");
|
password = getIntent().getStringExtra("password");
|
||||||
setContentView(R.layout.activity_bucket_select);
|
setContentView(R.layout.activity_bucket_select);
|
||||||
Region region = Region.getRegion(US_EAST_1);
|
Region region = Region.getRegion(US_EAST_1);
|
||||||
S3ClientOptions s3ClientOptions = S3ClientOptions.builder().build();
|
S3ClientOptions s3ClientOptions = S3ClientOptions.builder().build();
|
||||||
|
@ -100,5 +103,26 @@ public class BucketSelect extends AppCompatActivity {
|
||||||
listbucket.start();
|
listbucket.start();
|
||||||
//listbucket list = new listbucket();
|
//listbucket list = new listbucket();
|
||||||
//list.execute("test");
|
//list.execute("test");
|
||||||
|
recyclerView.addOnItemTouchListener(new RecyclerTouchListener(getApplicationContext(), recyclerView, new RecyclerTouchListener.ClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view, int position) {
|
||||||
|
System.out.println("Click on "+Integer.toString(position));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLongClick(View view, int position) {
|
||||||
|
System.out.println("Long click on "+Integer.toString(position));
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void explorer() {
|
||||||
|
|
||||||
|
Intent intent = new Intent(this, BucketSelect.class);
|
||||||
|
intent.putExtra("endpoint", endpoint);
|
||||||
|
intent.putExtra("username", username);
|
||||||
|
intent.putExtra("password", password);
|
||||||
|
startActivity(intent);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
14
app/src/main/java/asgardius/page/s3manager/ObjectSelect.java
Normal file
14
app/src/main/java/asgardius/page/s3manager/ObjectSelect.java
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
package asgardius.page.s3manager;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
public class ObjectSelect extends AppCompatActivity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_object_select);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
package asgardius.page.s3manager;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.GestureDetector;
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
public class RecyclerTouchListener implements RecyclerView.OnItemTouchListener {
|
||||||
|
|
||||||
|
private GestureDetector gestureDetector;
|
||||||
|
private ClickListener clickListener;
|
||||||
|
|
||||||
|
public RecyclerTouchListener(Context context, final RecyclerView recyclerView, final ClickListener clickListener) {
|
||||||
|
this.clickListener = clickListener;
|
||||||
|
gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onSingleTapUp(MotionEvent e) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLongPress(MotionEvent e) {
|
||||||
|
View child = recyclerView.findChildViewUnder(e.getX(), e.getY());
|
||||||
|
if (child != null && clickListener != null) {
|
||||||
|
clickListener.onLongClick(child, recyclerView.getChildPosition(child));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
|
||||||
|
|
||||||
|
View child = rv.findChildViewUnder(e.getX(), e.getY());
|
||||||
|
if (child != null && clickListener != null && gestureDetector.onTouchEvent(e)) {
|
||||||
|
clickListener.onClick(child, rv.getChildPosition(child));
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTouchEvent(RecyclerView rv, MotionEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface ClickListener {
|
||||||
|
void onClick(View view, int position);
|
||||||
|
|
||||||
|
void onLongClick(View view, int position);
|
||||||
|
}
|
||||||
|
}
|
9
app/src/main/res/layout/activity_object_select.xml
Normal file
9
app/src/main/res/layout/activity_object_select.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".ObjectSelect">
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in a new issue