Skip to content

Commit

Permalink
fixed empty data click
Browse files Browse the repository at this point in the history
  • Loading branch information
p32929 committed Aug 9, 2019
1 parent b425227 commit 94fc659
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 67 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ allprojects {
Add the dependency
```
dependencies {
implementation 'com.github.p32929:OfficeAbout:1.0.0.3'
implementation 'com.github.p32929:OfficeAbout:1.0.0.4'
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,90 +69,80 @@ public void onJsonDataReceived(final OfficeInfo officeInfo) {
members.addAll(officeInfo.getMembers());
adapter.notifyDataSetChanged();

if (officeInfo.getOfficeLogoUrl().isEmpty()) {
imageViewOfficeLogo.setVisibility(View.GONE);
} else {
imageViewOfficeLogo.setVisibility(View.VISIBLE);
Picasso.get().load(officeInfo.getOfficeLogoUrl()).into(imageViewOfficeLogo);
}

if (officeInfo.getOfficeLogoUrl().isEmpty()) {
imageViewGooglePlay.setVisibility(View.GONE);
} else {
imageViewGooglePlay.setVisibility(View.VISIBLE);
imageViewGooglePlay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Picasso.get().load(officeInfo.getOfficeLogoUrl()).into(imageViewOfficeLogo);

imageViewGooglePlay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (isAvailable(officeInfo.getGooglePlayUrl())) {
Intent browse = new Intent(Intent.ACTION_VIEW, Uri.parse(officeInfo.getGooglePlayUrl()));
startActivity(browse);
} else {
Toast.makeText(OfficeAboutActivity.this, "URL is not provided yet", Toast.LENGTH_SHORT).show();
}
});
}

if (officeInfo.getOfficeLogoUrl().isEmpty()) {
imageViewFacebook.setVisibility(View.GONE);
} else {
imageViewFacebook.setVisibility(View.VISIBLE);
imageViewFacebook.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});

imageViewFacebook.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (isAvailable(officeInfo.getFacebookUrl())) {
Intent browse = new Intent(Intent.ACTION_VIEW, Uri.parse(officeInfo.getFacebookUrl()));
startActivity(browse);
} else {
Toast.makeText(OfficeAboutActivity.this, "URL is not provided yet", Toast.LENGTH_SHORT).show();
}
});
}

if (officeInfo.getOfficeLogoUrl().isEmpty()) {
imageViewGroup.setVisibility(View.GONE);
} else {
imageViewGroup.setVisibility(View.VISIBLE);
imageViewGroup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});

imageViewGroup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (isAvailable(officeInfo.getGroupUrl())) {
Intent browse = new Intent(Intent.ACTION_VIEW, Uri.parse(officeInfo.getGroupUrl()));
startActivity(browse);
} else {
Toast.makeText(OfficeAboutActivity.this, "URL is not provided yet", Toast.LENGTH_SHORT).show();
}
});
}

if (officeInfo.getOfficeLogoUrl().isEmpty()) {
imageViewYoutube.setVisibility(View.GONE);
} else {
imageViewYoutube.setVisibility(View.VISIBLE);
imageViewYoutube.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});

imageViewYoutube.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (isAvailable(officeInfo.getYoutubeUrl())) {
Intent browse = new Intent(Intent.ACTION_VIEW, Uri.parse(officeInfo.getYoutubeUrl()));
startActivity(browse);
} else {
Toast.makeText(OfficeAboutActivity.this, "URL is not provided yet", Toast.LENGTH_SHORT).show();
}
});
}

if (officeInfo.getOfficeLogoUrl().isEmpty()) {
imageViewGithub.setVisibility(View.GONE);
} else {
imageViewGithub.setVisibility(View.VISIBLE);
imageViewGithub.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});

imageViewGithub.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (isAvailable(officeInfo.getGithubUrl())) {
Intent browse = new Intent(Intent.ACTION_VIEW, Uri.parse(officeInfo.getGithubUrl()));
startActivity(browse);
} else {
Toast.makeText(OfficeAboutActivity.this, "URL is not provided yet", Toast.LENGTH_SHORT).show();
}
});
}

if (officeInfo.getOfficeLogoUrl().isEmpty()) {
imageViewWeb.setVisibility(View.GONE);
} else {
imageViewWeb.setVisibility(View.VISIBLE);
imageViewWeb.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});

imageViewWeb.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (isAvailable(officeInfo.getWebUrl())) {
Intent browse = new Intent(Intent.ACTION_VIEW, Uri.parse(officeInfo.getWebUrl()));
startActivity(browse);
} else {
Toast.makeText(OfficeAboutActivity.this, "URL is not provided yet", Toast.LENGTH_SHORT).show();
}
});
}
}
});


swipeRefreshLayout.setRefreshing(false);
swipeRefreshLayout.setEnabled(false);
Expand All @@ -166,4 +156,16 @@ public void onError(String error) {
}
}).execute();
}

private boolean isAvailable(String something) {
if (something == null) {
return false;
} else {
if (something.isEmpty()) {
return false;
} else {
return true;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
android:layout_width="match_parent"
android:layout_height="175dp"
android:adjustViewBounds="true"
android:layout_marginBottom="8dp"
android:scaleType="centerInside" />

<LinearLayout
Expand Down

0 comments on commit 94fc659

Please sign in to comment.