From f480d719de1ef57d75720d9f6c27526bfd45f4b5 Mon Sep 17 00:00:00 2001 From: Tanmay Dixit Date: Mon, 25 Jun 2018 23:21:57 +0530 Subject: [PATCH 1/4] Speakers issue #15 --- .idea/misc.xml | 2 +- app/build.gradle | 5 +- app/src/main/AndroidManifest.xml | 1 + .../macbitsgoa/events/home/HomeActivity.java | 16 +++- .../events/speakers/SpeakerCardFragment.java | 59 ++++++++++++ .../events/speakers/SpeakersActivity.java | 73 +++++++++++++++ .../events/speakers/SpeakersAdapter.java | 90 +++++++++++++++++++ app/src/main/res/layout/activity_speakers.xml | 17 ++++ .../res/layout/fragment_speakers_card.xml | 14 +++ .../main/res/layout/item_speaker_details.xml | 58 ++++++++++++ app/src/main/res/values/strings.xml | 1 + build.gradle | 4 +- 12 files changed, 333 insertions(+), 7 deletions(-) create mode 100644 app/src/main/java/com/macbitsgoa/events/speakers/SpeakerCardFragment.java create mode 100644 app/src/main/java/com/macbitsgoa/events/speakers/SpeakersActivity.java create mode 100644 app/src/main/java/com/macbitsgoa/events/speakers/SpeakersAdapter.java create mode 100644 app/src/main/res/layout/activity_speakers.xml create mode 100644 app/src/main/res/layout/fragment_speakers_card.xml create mode 100644 app/src/main/res/layout/item_speaker_details.xml diff --git a/.idea/misc.xml b/.idea/misc.xml index cc51e58..f6e0e04 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -25,7 +25,7 @@ - + diff --git a/app/build.gradle b/app/build.gradle index d83aba7..0bbae18 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -22,9 +22,10 @@ android { resValue "bool", "eateries", "true" buildConfigField "boolean", "feed", "true" resValue "bool", "feed", "true" + buildConfigField "boolean", "speakers", "true" buildConfigField "boolean", "shouldShowMapOnHome", "true" buildConfigField "boolean", "timeline", "true" - buildConfigField "boolean","sponsors","true" + buildConfigField "boolean", "sponsors", "true" buildConfigField "int", "eventDuration", "4" // days buildConfigField "String", "startDate", "\"30,05,2018\"" // "dd,mm,yyyy" buildConfigField "String", "startDateFormat", "\"dd,MM,yyyy\"" @@ -68,7 +69,7 @@ dependencies { implementation 'androidx.constraintlayout:constraintlayout:1.1.2' implementation 'com.google.android.material:material:1.0.0-alpha3' implementation 'com.google.firebase:firebase-database:16.0.1' - implementation 'com.google.firebase:firebase-core:16.0.0' + implementation 'com.google.firebase:firebase-core:16.0.1' implementation 'androidx.legacy:legacy-support-v4:1.0.0-alpha3' implementation 'androidx.legacy:legacy-support-v13:1.0.0-alpha3' implementation 'androidx.appcompat:appcompat:1.0.0-alpha3' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 21dd002..abee300 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -97,6 +97,7 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/macbitsgoa/events/home/HomeActivity.java b/app/src/main/java/com/macbitsgoa/events/home/HomeActivity.java index 72f7c55..dde0861 100644 --- a/app/src/main/java/com/macbitsgoa/events/home/HomeActivity.java +++ b/app/src/main/java/com/macbitsgoa/events/home/HomeActivity.java @@ -11,6 +11,8 @@ import com.macbitsgoa.events.aboutfest.AboutEventActivity; import com.macbitsgoa.events.aboutmac.AboutMacActivity; import com.macbitsgoa.events.eateries.EateriesCardFragment; +import com.macbitsgoa.events.speakers.SpeakerCardFragment; +import com.macbitsgoa.events.speakers.SpeakersActivity; import com.macbitsgoa.events.sponsors.SponsorsFragment; import com.macbitsgoa.events.feed.FeedCardFragment; import com.macbitsgoa.events.maps.MapCardFragment; @@ -92,13 +94,18 @@ private void populateFeatures() { "map"); } - if (BuildConfig.sponsors){ + if (BuildConfig.sponsors) { fragmentTransaction.add(R.id.ll_home, new SponsorsFragment(), "sponsors"); } - + if (BuildConfig.speakers) { + fragmentTransaction.add(R.id.ll_home, + SpeakerCardFragment.newInstance(), + getString(R.string.frag_label_speakers) + ); + } fragmentTransaction.commit(); } @@ -162,6 +169,11 @@ public boolean onNavigationItemSelected(@NonNull final MenuItem menuItem) { break; } + case (R.id.nav_speakers): { + final Intent speakersIntent = new Intent(HomeActivity.this, SpeakersActivity.class); + startActivity(speakersIntent); + break; + } default: { break; } diff --git a/app/src/main/java/com/macbitsgoa/events/speakers/SpeakerCardFragment.java b/app/src/main/java/com/macbitsgoa/events/speakers/SpeakerCardFragment.java new file mode 100644 index 0000000..a007b85 --- /dev/null +++ b/app/src/main/java/com/macbitsgoa/events/speakers/SpeakerCardFragment.java @@ -0,0 +1,59 @@ +package com.macbitsgoa.events.speakers; + +import android.content.Intent; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.google.android.material.card.MaterialCardView; +import com.macbitsgoa.events.R; +import com.macbitsgoa.events.home.HomeCardInterface; + +import androidx.fragment.app.Fragment; + +/* + * Created by Hariram.R + * 13/06/2018 + * */ + +public class SpeakerCardFragment extends Fragment implements View.OnClickListener, + HomeCardInterface { + + private MaterialCardView cardView; + + + public static SpeakerCardFragment newInstance() { + SpeakerCardFragment fragment = new SpeakerCardFragment(); + Bundle bundle = new Bundle(); + fragment.setArguments(bundle); + + return fragment; + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + cardView = (MaterialCardView) inflater.inflate(R.layout.fragment_speakers_card, + container, false); + return cardView; + } + + @Override + public void onClick(View view) { + Intent intentToSpeakersActivity = new Intent(view.getContext(), SpeakersActivity.class); + startActivity(intentToSpeakersActivity); + } + + @Override + public void onResume() { + super.onResume(); + cardView.setOnClickListener(this); + } + + @Override + public void onPause() { + super.onPause(); + cardView.setOnClickListener(null); + } +} diff --git a/app/src/main/java/com/macbitsgoa/events/speakers/SpeakersActivity.java b/app/src/main/java/com/macbitsgoa/events/speakers/SpeakersActivity.java new file mode 100644 index 0000000..ae20291 --- /dev/null +++ b/app/src/main/java/com/macbitsgoa/events/speakers/SpeakersActivity.java @@ -0,0 +1,73 @@ +package com.macbitsgoa.events.speakers; + +import android.os.Bundle; +import android.util.Log; + +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.macbitsgoa.events.R; + +import java.util.ArrayList; + +import androidx.fragment.app.FragmentActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +/* + * Created by Hariram.R + * 13/06/2018 + * */ + +public class SpeakersActivity extends FragmentActivity { + private ArrayList nameList; + private ArrayList descList; + private ArrayList imgList; + private ArrayList clickList; + + DatabaseReference databaseReference; + + private static String TAG = SpeakersActivity.class.getSimpleName(); + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_speakers); + + RecyclerView speakersRV = findViewById(R.id.speakers_RV); + LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, + false); + speakersRV.setLayoutManager(layoutManager); + + nameList = new ArrayList<>(); + descList = new ArrayList<>(); + imgList = new ArrayList<>(); + clickList = new ArrayList<>(); + databaseReference = FirebaseDatabase.getInstance().getReference().child("speakers"); + databaseReference.keepSynced(true); + databaseReference.addValueEventListener(new ValueEventListener() { + @Override + public void onDataChange(DataSnapshot dataSnapshot) { + for (DataSnapshot child : dataSnapshot.getChildren()) { + + nameList.add(child.child("name").getValue(String.class)); + descList.add(child.child("desc").getValue(String.class)); + imgList.add(child.child("imageUrl").getValue(String.class)); + clickList.add(child.child("onClickUrl").getValue(String.class)); + } + SpeakersAdapter adapter = new SpeakersAdapter(nameList, descList, imgList, + clickList, SpeakersActivity.this); + speakersRV.setAdapter(adapter); + } + + @Override + public void onCancelled(DatabaseError databaseError) { + Log.e(TAG, databaseError.getMessage()); + + } + }); + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/macbitsgoa/events/speakers/SpeakersAdapter.java b/app/src/main/java/com/macbitsgoa/events/speakers/SpeakersAdapter.java new file mode 100644 index 0000000..f34d512 --- /dev/null +++ b/app/src/main/java/com/macbitsgoa/events/speakers/SpeakersAdapter.java @@ -0,0 +1,90 @@ +package com.macbitsgoa.events.speakers; + +import android.content.Context; +import android.content.Intent; +import android.net.Uri; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import com.facebook.drawee.view.SimpleDraweeView; +import com.macbitsgoa.events.R; + +import java.util.ArrayList; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +/* + * Created by Hariram.R + * 13/06/2018 + * */ + +public class SpeakersAdapter extends RecyclerView.Adapter { + + private ArrayList NameList = new ArrayList<>(); + private ArrayList DescList = new ArrayList<>(); + private ArrayList imgList = new ArrayList<>(); + private ArrayList clickList = new ArrayList<>(); + + private Context context; + + private static String TAG = SpeakersAdapter.class.getSimpleName(); + + public SpeakersAdapter(ArrayList nameList, ArrayList descList, ArrayList imgList, ArrayList clickList, Context context) { + NameList = nameList; + DescList = descList; + this.imgList = imgList; + this.clickList = clickList; + this.context = context; + } + + @NonNull + @Override + public SpeakerViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext()); + View view = layoutInflater.inflate(R.layout.item_speaker_details, parent, false); + SpeakerViewHolder viewHolder = new SpeakerViewHolder(view); + return viewHolder; + + } + + @Override + public void onBindViewHolder(@NonNull final SpeakerViewHolder holder, final int position) { + + //Log.e(TAG,"Binding all data"); + + holder.imageV.setImageURI(imgList.get(position)); + holder.descTV.setText(DescList.get(position)); + holder.nameTV.setText(NameList.get(position)); + holder.imageV.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + String url = clickList.get(position); + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setData(Uri.parse(url)); + context.startActivity(intent); + } + }); + } + + @Override + public int getItemCount() { + return NameList.size(); + } + + public class SpeakerViewHolder extends RecyclerView.ViewHolder { + TextView nameTV; + TextView descTV; + SimpleDraweeView imageV; + + public SpeakerViewHolder(View itemView) { + super(itemView); + imageV = itemView.findViewById(R.id.speaker_image); + nameTV = itemView.findViewById(R.id.speaker_name); + descTV = itemView.findViewById(R.id.speaker_desc); + } + } +} diff --git a/app/src/main/res/layout/activity_speakers.xml b/app/src/main/res/layout/activity_speakers.xml new file mode 100644 index 0000000..40662dc --- /dev/null +++ b/app/src/main/res/layout/activity_speakers.xml @@ -0,0 +1,17 @@ + + + + + + + + + diff --git a/app/src/main/res/layout/fragment_speakers_card.xml b/app/src/main/res/layout/fragment_speakers_card.xml new file mode 100644 index 0000000..c09b940 --- /dev/null +++ b/app/src/main/res/layout/fragment_speakers_card.xml @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_speaker_details.xml b/app/src/main/res/layout/item_speaker_details.xml new file mode 100644 index 0000000..058fd37 --- /dev/null +++ b/app/src/main/res/layout/item_speaker_details.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 105d7c5..aa6e5fb 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -25,4 +25,5 @@ Feed Map Sponsors + Speakers diff --git a/build.gradle b/build.gradle index 924aad0..70a6455 100644 --- a/build.gradle +++ b/build.gradle @@ -1,13 +1,13 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - + repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.2.0-alpha18' + classpath 'com.android.tools.build:gradle:3.2.0-beta01' classpath 'com.google.gms:google-services:4.0.1' // NOTE: Do not place your application dependencies here; they belong From c651454cf2760997321c12c4e90ac2260000364a Mon Sep 17 00:00:00 2001 From: Tanmay Dixit Date: Mon, 25 Jun 2018 23:29:34 +0530 Subject: [PATCH 2/4] codacy issues --- .../macbitsgoa/events/speakers/SpeakersActivity.java | 2 +- .../macbitsgoa/events/speakers/SpeakersAdapter.java | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/macbitsgoa/events/speakers/SpeakersActivity.java b/app/src/main/java/com/macbitsgoa/events/speakers/SpeakersActivity.java index ae20291..ebbfe55 100644 --- a/app/src/main/java/com/macbitsgoa/events/speakers/SpeakersActivity.java +++ b/app/src/main/java/com/macbitsgoa/events/speakers/SpeakersActivity.java @@ -27,7 +27,7 @@ public class SpeakersActivity extends FragmentActivity { private ArrayList imgList; private ArrayList clickList; - DatabaseReference databaseReference; + private DatabaseReference databaseReference; private static String TAG = SpeakersActivity.class.getSimpleName(); diff --git a/app/src/main/java/com/macbitsgoa/events/speakers/SpeakersAdapter.java b/app/src/main/java/com/macbitsgoa/events/speakers/SpeakersAdapter.java index f34d512..e8f0e80 100644 --- a/app/src/main/java/com/macbitsgoa/events/speakers/SpeakersAdapter.java +++ b/app/src/main/java/com/macbitsgoa/events/speakers/SpeakersAdapter.java @@ -3,7 +3,6 @@ import android.content.Context; import android.content.Intent; import android.net.Uri; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -31,8 +30,6 @@ public class SpeakersAdapter extends RecyclerView.Adapter nameList, ArrayList descList, ArrayList imgList, ArrayList clickList, Context context) { NameList = nameList; DescList = descList; @@ -54,8 +51,6 @@ public SpeakerViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewT @Override public void onBindViewHolder(@NonNull final SpeakerViewHolder holder, final int position) { - //Log.e(TAG,"Binding all data"); - holder.imageV.setImageURI(imgList.get(position)); holder.descTV.setText(DescList.get(position)); holder.nameTV.setText(NameList.get(position)); @@ -76,9 +71,9 @@ public int getItemCount() { } public class SpeakerViewHolder extends RecyclerView.ViewHolder { - TextView nameTV; - TextView descTV; - SimpleDraweeView imageV; + private TextView nameTV; + private TextView descTV; + private SimpleDraweeView imageV; public SpeakerViewHolder(View itemView) { super(itemView); From 74b690df71e4f7590ec99ae6cb2c9fe84e56280e Mon Sep 17 00:00:00 2001 From: Tanmay Dixit Date: Mon, 25 Jun 2018 23:32:48 +0530 Subject: [PATCH 3/4] codacy issues --- .../com/macbitsgoa/events/speakers/SpeakersActivity.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/macbitsgoa/events/speakers/SpeakersActivity.java b/app/src/main/java/com/macbitsgoa/events/speakers/SpeakersActivity.java index ebbfe55..5dba1d7 100644 --- a/app/src/main/java/com/macbitsgoa/events/speakers/SpeakersActivity.java +++ b/app/src/main/java/com/macbitsgoa/events/speakers/SpeakersActivity.java @@ -27,8 +27,6 @@ public class SpeakersActivity extends FragmentActivity { private ArrayList imgList; private ArrayList clickList; - private DatabaseReference databaseReference; - private static String TAG = SpeakersActivity.class.getSimpleName(); @Override @@ -45,7 +43,8 @@ protected void onCreate(Bundle savedInstanceState) { descList = new ArrayList<>(); imgList = new ArrayList<>(); clickList = new ArrayList<>(); - databaseReference = FirebaseDatabase.getInstance().getReference().child("speakers"); + DatabaseReference databaseReference = FirebaseDatabase.getInstance() + .getReference().child("speakers"); databaseReference.keepSynced(true); databaseReference.addValueEventListener(new ValueEventListener() { @Override From cc50be922535ff810fd4c2c62edcbeb014551213 Mon Sep 17 00:00:00 2001 From: Tanmay Dixit Date: Tue, 26 Jun 2018 14:01:45 +0530 Subject: [PATCH 4/4] REQUESTED issues --- .idea/misc.xml | 2 +- .../java/com/macbitsgoa/events/home/HomeActivity.java | 2 +- .../macbitsgoa/events/speakers/SpeakerCardFragment.java | 9 --------- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index f6e0e04..cc51e58 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -25,7 +25,7 @@ - + diff --git a/app/src/main/java/com/macbitsgoa/events/home/HomeActivity.java b/app/src/main/java/com/macbitsgoa/events/home/HomeActivity.java index dde0861..7eab1a5 100644 --- a/app/src/main/java/com/macbitsgoa/events/home/HomeActivity.java +++ b/app/src/main/java/com/macbitsgoa/events/home/HomeActivity.java @@ -102,7 +102,7 @@ private void populateFeatures() { } if (BuildConfig.speakers) { fragmentTransaction.add(R.id.ll_home, - SpeakerCardFragment.newInstance(), + new SpeakerCardFragment(), getString(R.string.frag_label_speakers) ); } diff --git a/app/src/main/java/com/macbitsgoa/events/speakers/SpeakerCardFragment.java b/app/src/main/java/com/macbitsgoa/events/speakers/SpeakerCardFragment.java index a007b85..4bf96c6 100644 --- a/app/src/main/java/com/macbitsgoa/events/speakers/SpeakerCardFragment.java +++ b/app/src/main/java/com/macbitsgoa/events/speakers/SpeakerCardFragment.java @@ -22,15 +22,6 @@ public class SpeakerCardFragment extends Fragment implements View.OnClickListene private MaterialCardView cardView; - - public static SpeakerCardFragment newInstance() { - SpeakerCardFragment fragment = new SpeakerCardFragment(); - Bundle bundle = new Bundle(); - fragment.setArguments(bundle); - - return fragment; - } - @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {