NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

package com.bt.soulmate.activities;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.bt.soulmate.R;
import com.bt.soulmate.swipeActivity;
import com.bt.soulmate.utils.HarmonyAlgorithm;
import com.bumptech.glide.Glide;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import static com.bt.soulmate.swipeActivity.viewHolder;

public class showMatches extends AppCompatActivity {
Map userInfo;
FirebaseAuth mAuth;
ListView listView;
private ArrayList<HarmonyAlgorithm> persons;
String id;
private CustomAdapter listViewAdapter;
public static ArrayList<HarmonyAlgorithm> h;
HarmonyAlgorithm harmo;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_show_matches);
listView = (ListView)findViewById(R.id.listview_matches);

h = new ArrayList<HarmonyAlgorithm>();



mAuth = FirebaseAuth.getInstance();
id = mAuth.getCurrentUser().getUid();
DatabaseReference currentUserDb = FirebaseDatabase.getInstance().getReference().child("Users").child(id).child("matches");

currentUserDb.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
if (dataSnapshot != null) {

for(DataSnapshot ds : dataSnapshot.getChildren()) {


harmo = new HarmonyAlgorithm();
harmo.setUserID(ds.getKey().toString());

harmo.ChatId = ds.child("ChatId").getValue().toString();


DatabaseReference currentUserDbs = FirebaseDatabase.getInstance().getReference().child("Users").child(harmo.getUserID());
currentUserDbs.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
try {
harmo.setName(dataSnapshot.child("name").getValue().toString());
harmo.setProfilFoto(dataSnapshot.child("profilFoto").getValue().toString());
}catch (Exception e){

}

}

@Override
public void onCancelled(@NonNull DatabaseError databaseError) {

}
});

h.add(harmo);
}

}

}


@Override
public void onCancelled(@NonNull DatabaseError databaseError) {

}
});



CountDownTimer countDownTimer= new CountDownTimer(3000,1000){
@Override
public void onTick(long millisUntilFinished) {

}

@Override
public void onFinish() {
listViewAdapter = new CustomAdapter(showMatches.this,h);
listView.setAdapter(listViewAdapter);
}
}.start();






}


public class CustomAdapter extends ArrayAdapter<HarmonyAlgorithm>{

private LayoutInflater inflater;
private Context context;
private ViewHolder holder;
private ArrayList<HarmonyAlgorithm> harmony;


public CustomAdapter(@NonNull Context context, ArrayList<HarmonyAlgorithm> harmony) {
super(context,0,harmony);

this.context = context;
this.harmony = harmony;
inflater = LayoutInflater.from(context);
}

@Override
public int getCount() {
return harmony.size();
}

@Override
public HarmonyAlgorithm getItem(int position) {
return harmony.get(position);
}

@Override
public long getItemId(int position) {
return harmony.get(position).hashCode();
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {

if (convertView == null) {

convertView = inflater.inflate(R.layout.custom_listview_new_match_vertical, null);

holder = new ViewHolder();
holder.personImage = (ImageView) convertView.findViewById(R.id.paymentlogo);
holder.personNameLabel = (TextView) convertView.findViewById(R.id.textView34);
// holder.personAddressLabel = (TextView) convertView.findViewById(R.id.person_address_label);
convertView.setTag(holder);

}
else{
//Get viewholder we already created
holder = (ViewHolder)convertView.getTag();
}

HarmonyAlgorithm Harmony = harmony.get(position);
if(Harmony != null){
try {
Glide.with(showMatches.this).load(harmony.get(position).getProfilFoto()).into(holder.personImage);
holder.personNameLabel.setText(harmony.get(position).getName());
//holder.personAddressLabel.setText(Harmony.getAddress());
}catch (Exception e){

}
}
return convertView;
}

//View Holder Pattern for better performance
private class ViewHolder {
TextView personNameLabel;
TextView personAddressLabel;
ImageView personImage;

}
}}




////////////////////////////////////////////
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:backgroundTint="@android:color/white"
android:background="?attr/colorPrimary">



<TextView
android:id="@+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Soulmate"
android:textColor="#BE74FF"
android:textSize="25sp"
android:textStyle="bold" />

<ImageButton
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
style="?android:attr/borderlessButtonStyle"
android:src="@drawable/ic_user"
/>

<ImageButton
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
style="?android:attr/borderlessButtonStyle"
android:src="@drawable/ic_speech_bubble"
/>

</androidx.appcompat.widget.Toolbar>

<TextView
android:id="@+id/textView23"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingTop="10dp"
android:text="Yeni Eşleşmeler"
android:textColor="#BE74FF"
android:textSize="18sp"
android:textStyle="bold" />

<ListView
android:id="@+id/listview_matches"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="5dp" />


</LinearLayout>

     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.