2020-03-01 21:13:11
package com.xbsaykat.easy24admin.DailyMarketing;
 
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
 
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
 
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 com.xbsaykat.easy24admin.R;
 
import java.util.ArrayList;
 
public class CheckDay extends AppCompatActivity {
    String mid;
    DatabaseReference  mUsers;
    public static final String KEY_Month ="KEY_Month" ;
    public static final String KEY_id ="KEY_id" ;
    ListView List;
    ArrayList<String> arraylist;
    ArrayAdapter<String> arrayAdapter;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 
        setContentView(R.layout.checkmonth);
        Intent intent = getIntent();
        mid = intent.getStringExtra("marketerid");
 
        mUsers = FirebaseDatabase.getInstance().getReference().child("MarketerDate").child(mid);
        List=findViewById(R.id.userlistview);
        arraylist=new ArrayList<>();
 
 
        arrayAdapter=new ArrayAdapter<String>(CheckDay.this,android.R.layout.simple_list_item_1, arraylist){
            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                View view = super.getView(position, convertView, parent);
                TextView tv = (TextView) view.findViewById(android.R.id.text1);
                // Set the text color of TextView (ListView Item)
                tv.setTextColor(Color.BLACK);
                tv.setAllCaps(true);
                tv.setTypeface(tv.getTypeface(), Typeface.BOLD);
                tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP,18);
                // Generate ListView Item using TextView
                return view;
            }
        };
        List.setAdapter(arrayAdapter);
 
        mUsers.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                for(DataSnapshot snapshot:dataSnapshot.getChildren()){
                    String ID=snapshot.getKey();
                    arraylist.add(ID);
                    arrayAdapter.notifyDataSetChanged();
                }
            }
 
            @Override
            public void onCancelled(DatabaseError databaseError) {
 
            }
        });
 
        List.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Toast.makeText(CheckDay.this, "Item in position " + position + " clicked : "+ arraylist.get(position),Toast.LENGTH_LONG).show();
                Intent intent = new Intent(CheckDay.this, CheckUsers.class);
                Bundle bundle=new Bundle();
                bundle.putString(KEY_id, mid);
                bundle.putString(KEY_Month, arraylist.get(position));
                intent.putExtras(bundle);
                startActivity(intent);
            }
        });
 
    }
 
}
------------------------------------------------------------------
package com.xbsaykat.easy24admin.DailyMarketing;
 
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
 
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
 
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
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 com.xbsaykat.easy24admin.R;
 
import java.util.ArrayList;
 
public class CheckUsers extends AppCompatActivity {
    String MarketerKEY_id,MarketerKEY_Month;
    DatabaseReference mUsers;
    public static final String KEY_Month ="KEY_Month" ;
    public static final String KEY_id ="KEY_id" ;
    ListView List;
    ArrayList<String> arraylist;
    ArrayAdapter<String> arrayAdapter;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 
        setContentView(R.layout.checkusers);
 
 
 
        List=findViewById(R.id.userlistview);
        arraylist=new ArrayList<>();
 
 
        arrayAdapter=new ArrayAdapter<String>(CheckUsers.this,android.R.layout.simple_list_item_1, arraylist){
            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                View view = super.getView(position, convertView, parent);
                TextView tv = (TextView) view.findViewById(android.R.id.text1);
                // Set the text color of TextView (ListView Item)
                tv.setTextColor(Color.BLACK);
                tv.setAllCaps(true);
                tv.setTypeface(tv.getTypeface(), Typeface.BOLD);
                tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP,18);
                // Generate ListView Item using TextView
                return view;
            }
        };
        List.setAdapter(arrayAdapter);
 
 
        Bundle bundle = getIntent().getExtras();
        if (bundle != null) {
            MarketerKEY_id = bundle.getString(KEY_id);
            MarketerKEY_Month = bundle.getString(KEY_Month);
            mUsers = FirebaseDatabase.getInstance().getReference().child("MarketerDate").child(MarketerKEY_id).child(MarketerKEY_Month);
            mUsers.addValueEventListener(new ValueEventListener() {
                @Override
                public void onDataChange(DataSnapshot dataSnapshot) {
                    for(DataSnapshot snapshot:dataSnapshot.getChildren()){
                        String ID=snapshot.child("mobile").getValue().toString();
                        arraylist.add(ID);
                        arrayAdapter.notifyDataSetChanged();
                    }
                }
 
                @Override
                public void onCancelled(DatabaseError databaseError) {
 
                }
            });
        }
        FloatingActionButton fab = findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Users : "+arraylist.size(), Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });
        List.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                //Toast.makeText(CheckUsers.this, "Item in position " + position + " clicked : "+ arraylist.get(position),Toast.LENGTH_LONG).show();
                //Intent intent = new Intent(CheckUsers.this, CheckUsers.class);
                //Bundle bundle=new Bundle();
               // bundle.putString(KEY_id, mid);
               // bundle.putString(KEY_Month, arraylist.get(position));
               // intent.putExtras(bundle);
               // startActivity(intent);
            }
        });
 
    }
 
}
 
Invalid Email or Password