There is no need to use JSONArray in Utils.loadProfiles()
You can replace the JSONArray with TypeToken and use GSON to parse the List<Profile> directly.
public class Utils {
@NonNull
public static List<Profile> loadProfiles(Context context) {
BufferedReader reader = null;
try {
AssetManager manager = context.getAssets();
InputStream inputStream = manager.open("profiles.json");
reader = new BufferedReader(new InputStreamReader(inputStream));
Gson gson = new Gson(); // TODO dependency injection
return gson.fromJson(reader, new TypeToken<ArrayList<Profile>>() {}.getType());
} catch(Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
} finally {
if(reader != null) {
try {
reader.close();
} catch(IOException e) {
// Ignore
}
}
}
}
}
@Zhuinden Sure
hello brother, i am wondering why do i get repeated views whens swiping.
@scorlingonzalez It's added again for the demo purpose.
what am trying to say is that i get repeated people while i swipe
also for some reason i can get the image to show
@scorlingonzalez you are referring to the TinderSwipe project or tinder-swipe-v2?
this is the link https://blog.mindorks.com/android-tinder-swipe-view-example-3eca9b0d4794
check this method:
@SwipeOut
private void onSwipedOut(){
Log.d("EVENT", "onSwipedOut");
mSwipeView.addView(this);
}
remove this line: mSwipeView.addView(this)
It adds the view again if removed.
@SwipeOut public void onSwipedOut() { mSwipeView.addView(this); }
i do have this method in the same format... it is usally random behavior for example i may get the same person twice in a row or just at random.. and also if let say an array has 3 people i can scroll like 15 or more time randomly repeating the people... do you think i can send you my code in facebook maybe u can help me out a bit please
i delete that line but still same behaviour