Skip to content

Commit c355633

Browse files
authored
Merge pull request #44 from vikendu/providers-home-fully-implemented
ProvidersHomeActivity.java functioning as designed.
2 parents 6123708 + 50d94c2 commit c355633

File tree

4 files changed

+29
-16
lines changed

4 files changed

+29
-16
lines changed

app/src/main/java/com/vikendu/theservicesapp/CreateAdActivity.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,19 @@ public class CreateAdActivity extends AppCompatActivity {
2626
private ArrayList<Advert> advertArrayList;
2727
private ServiceProvider mServiceProvider;
2828

29+
private boolean getApprovedAds;
30+
2931
@Override
3032
protected void onCreate(Bundle savedInstanceState) {
3133
super.onCreate(savedInstanceState);
3234
setContentView(R.layout.activity_create_ad);
3335

3436
adCardRv = findViewById(R.id.idRVAdCreation);
3537
advertArrayList = new ArrayList<>();
36-
// TODO: Get an Intent from where you are coming and Inflate the card view as per that
38+
39+
Bundle bundle = getIntent().getExtras();
40+
getApprovedAds = bundle.getBoolean("approved");
41+
3742
getDataSnapshot();
3843
}
3944

@@ -46,7 +51,12 @@ public void onDataChange(DataSnapshot dataSnapshot) {
4651
advertArrayList.clear();
4752
for(DataSnapshot adSnapshot : dataSnapshot.getChildren()) {
4853
ad = adSnapshot.getValue(Advert.class);
49-
advertArrayList.add(ad);
54+
if(getApprovedAds && ad.isApproved()) {
55+
advertArrayList.add(ad);
56+
}
57+
else if(!getApprovedAds && !ad.isApproved()) {
58+
advertArrayList.add(ad);
59+
}
5060
}
5161
getServiceProvider();
5262
}
@@ -58,7 +68,7 @@ public void onCancelled(DatabaseError databaseError) {
5868
mDatabaseAdvertRef.child(Objects.requireNonNull(getUid())).addValueEventListener(advertListener);
5969
}
6070

61-
public void getServiceProvider() {
71+
private void getServiceProvider() {
6272
DatabaseReference mDatabaseProviderRef = FirebaseDatabase.getInstance("https://the-services-app-default-rtdb.asia-southeast1.firebasedatabase.app").getReference("providers");
6373

6474
ValueEventListener serviceProviderListener = new ValueEventListener() {

app/src/main/java/com/vikendu/theservicesapp/LoginActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private void attemptLogin() {
104104
// TODO: rebuild the following function to redirect the user to the correct activity
105105
private void goToAdCreationTool()
106106
{
107-
Intent intent = new Intent(LoginActivity.this, CreateAdActivity.class);
107+
Intent intent = new Intent(LoginActivity.this, ProvidersHomeActivity.class);
108108
finish();
109109
startActivity(intent);
110110
}

app/src/main/java/com/vikendu/theservicesapp/ProvidersHomeActivity.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,12 @@
66
import android.os.Bundle;
77
import android.view.View;
88

9-
import com.vikendu.theservicesapp.util.FirebaseUtil;
10-
119
public class ProvidersHomeActivity extends AppCompatActivity {
1210

13-
private String uId;
14-
1511
@Override
1612
protected void onCreate(Bundle savedInstanceState) {
1713
super.onCreate(savedInstanceState);
1814
setContentView(R.layout.activity_providers_home);
19-
20-
uId = FirebaseUtil.getUid();
2115
}
2216

2317
public void goToAdCreationTool(View view) {
@@ -28,9 +22,18 @@ public void goToAdCreationTool(View view) {
2822

2923
public void goToPendingAdsActivity(View view) {
3024
// TODO: go to the same activity as that of the FEED just fill it up with req data
25+
Intent intent = new Intent(this, CreateAdActivity.class);
26+
intent.putExtra("approved", false);
27+
finish();
28+
startActivity(intent);
29+
3130
}
3231

3332
public void goToApprovedAdsActivity(View view) {
3433
// TODO: go to the same activity as that of the FEED just fill it up with req data
34+
Intent intent = new Intent(this, CreateAdActivity.class);
35+
intent.putExtra("approved", true);
36+
finish();
37+
startActivity(intent);
3538
}
3639
}

app/src/main/java/com/vikendu/theservicesapp/model/Advert.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class Advert {
77
private String tagLine;
88
private String adDescription;
99
private String adPrice;
10-
private boolean approval;
10+
private boolean approved;
1111
private boolean isLive;
1212

1313
public String getTagLine() {
@@ -50,12 +50,12 @@ public void setCategory1(String category1) {
5050
this.category1 = category1;
5151
}
5252

53-
public boolean isApproval() {
54-
return approval;
53+
public boolean isApproved() {
54+
return approved;
5555
}
5656

57-
public void setApproval(boolean approval) {
58-
this.approval = approval;
57+
public void setApproved(boolean approved) {
58+
this.approved = approved;
5959
}
6060

6161
public boolean isLive() {
@@ -72,7 +72,7 @@ public Advert(String category0, String category1, String tagLine, String adDescr
7272
this.tagLine = tagLine;
7373
this.adDescription = adDescription;
7474
this.adPrice = adPrice;
75-
this.approval = approval;
75+
this.approved = approval;
7676
this.isLive = isLive;
7777
}
7878
public Advert() { }

0 commit comments

Comments
 (0)