Skip to content

Commit

Permalink
Merge pull request #44 from vikendu/providers-home-fully-implemented
Browse files Browse the repository at this point in the history
ProvidersHomeActivity.java functioning as designed.
  • Loading branch information
vikendu authored Jun 12, 2021
2 parents 6123708 + 50d94c2 commit c355633
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 16 deletions.
16 changes: 13 additions & 3 deletions app/src/main/java/com/vikendu/theservicesapp/CreateAdActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,19 @@ public class CreateAdActivity extends AppCompatActivity {
private ArrayList<Advert> advertArrayList;
private ServiceProvider mServiceProvider;

private boolean getApprovedAds;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create_ad);

adCardRv = findViewById(R.id.idRVAdCreation);
advertArrayList = new ArrayList<>();
// TODO: Get an Intent from where you are coming and Inflate the card view as per that

Bundle bundle = getIntent().getExtras();
getApprovedAds = bundle.getBoolean("approved");

getDataSnapshot();
}

Expand All @@ -46,7 +51,12 @@ public void onDataChange(DataSnapshot dataSnapshot) {
advertArrayList.clear();
for(DataSnapshot adSnapshot : dataSnapshot.getChildren()) {
ad = adSnapshot.getValue(Advert.class);
advertArrayList.add(ad);
if(getApprovedAds && ad.isApproved()) {
advertArrayList.add(ad);
}
else if(!getApprovedAds && !ad.isApproved()) {
advertArrayList.add(ad);
}
}
getServiceProvider();
}
Expand All @@ -58,7 +68,7 @@ public void onCancelled(DatabaseError databaseError) {
mDatabaseAdvertRef.child(Objects.requireNonNull(getUid())).addValueEventListener(advertListener);
}

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

ValueEventListener serviceProviderListener = new ValueEventListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private void attemptLogin() {
// TODO: rebuild the following function to redirect the user to the correct activity
private void goToAdCreationTool()
{
Intent intent = new Intent(LoginActivity.this, CreateAdActivity.class);
Intent intent = new Intent(LoginActivity.this, ProvidersHomeActivity.class);
finish();
startActivity(intent);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,12 @@
import android.os.Bundle;
import android.view.View;

import com.vikendu.theservicesapp.util.FirebaseUtil;

public class ProvidersHomeActivity extends AppCompatActivity {

private String uId;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_providers_home);

uId = FirebaseUtil.getUid();
}

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

public void goToPendingAdsActivity(View view) {
// TODO: go to the same activity as that of the FEED just fill it up with req data
Intent intent = new Intent(this, CreateAdActivity.class);
intent.putExtra("approved", false);
finish();
startActivity(intent);

}

public void goToApprovedAdsActivity(View view) {
// TODO: go to the same activity as that of the FEED just fill it up with req data
Intent intent = new Intent(this, CreateAdActivity.class);
intent.putExtra("approved", true);
finish();
startActivity(intent);
}
}
12 changes: 6 additions & 6 deletions app/src/main/java/com/vikendu/theservicesapp/model/Advert.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class Advert {
private String tagLine;
private String adDescription;
private String adPrice;
private boolean approval;
private boolean approved;
private boolean isLive;

public String getTagLine() {
Expand Down Expand Up @@ -50,12 +50,12 @@ public void setCategory1(String category1) {
this.category1 = category1;
}

public boolean isApproval() {
return approval;
public boolean isApproved() {
return approved;
}

public void setApproval(boolean approval) {
this.approval = approval;
public void setApproved(boolean approved) {
this.approved = approved;
}

public boolean isLive() {
Expand All @@ -72,7 +72,7 @@ public Advert(String category0, String category1, String tagLine, String adDescr
this.tagLine = tagLine;
this.adDescription = adDescription;
this.adPrice = adPrice;
this.approval = approval;
this.approved = approval;
this.isLive = isLive;
}
public Advert() { }
Expand Down

0 comments on commit c355633

Please sign in to comment.