Handle empty interactions list.

This commit is contained in:
Mark Anderson 2015-06-17 20:29:41 +01:00
parent f4891f6783
commit c7475cccd0
3 changed files with 40 additions and 10 deletions

View file

@ -5,6 +5,30 @@
android:orientation="vertical"
style="?itemBackground" >
<RelativeLayout
android:id="@+id/empty_view"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/empty_view_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:gravity="center"
android:text="@string/empty_list_view_loading"
style="?defaultText"
android:textSize="13dp"
android:textStyle="italic" />
<com.newsblur.view.ProgressThrobber
android:id="@+id/empty_view_loading_throb"
android:layout_width="fill_parent"
android:layout_alignParentTop="true"
android:layout_height="6dp" />
</RelativeLayout>
<ListView
android:id="@+id/profile_details_activitylist"
android:layout_width="fill_parent"

View file

@ -93,6 +93,7 @@
<string name="profile_signup">You signed up for Newsblur</string>
<string name="profile_comments_on">comments on</string>
<string name="profile_feed_not_available">You are no longer subscribed to this feed</string>
<string name="profile_no_interactions">No interactions</string>
<string name="menu_profile">Profile</string>
<string name="menu_refresh">Refresh</string>

View file

@ -11,6 +11,7 @@ import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.newsblur.R;
@ -39,7 +40,7 @@ public abstract class ProfileActivityDetailsFragment extends Fragment implements
private ActivityDetailsAdapter adapter;
protected APIManager apiManager;
private UserDetails user;
private ProgressThrobber footerProgressView;
private ProgressThrobber loadingProgressView;
@Override
public void onCreate(Bundle savedInstanceState) {
@ -52,14 +53,13 @@ public abstract class ProfileActivityDetailsFragment extends Fragment implements
final View v = inflater.inflate(R.layout.fragment_profileactivity, null);
activityList = (ListView) v.findViewById(R.id.profile_details_activitylist);
View footerView = inflater.inflate(R.layout.row_loading_throbber, null);
footerProgressView = (ProgressThrobber) footerView.findViewById(R.id.itemlist_loading_throb);
footerProgressView.setColors(getResources().getColor(R.color.refresh_1),
getResources().getColor(R.color.refresh_2),
getResources().getColor(R.color.refresh_3),
getResources().getColor(R.color.refresh_4));
activityList.addFooterView(footerView, null, false);
loadingProgressView = (ProgressThrobber) v.findViewById(R.id.empty_view_loading_throb);
loadingProgressView.setColors(getResources().getColor(R.color.refresh_1),
getResources().getColor(R.color.refresh_2),
getResources().getColor(R.color.refresh_3),
getResources().getColor(R.color.refresh_4));
activityList.setFooterDividersEnabled(false);
activityList.setEmptyView(v.findViewById(R.id.empty_view));
if (adapter != null) {
displayActivities();
@ -85,7 +85,7 @@ public abstract class ProfileActivityDetailsFragment extends Fragment implements
@Override
protected void onPreExecute() {
footerProgressView.setVisibility(View.VISIBLE);
loadingProgressView.setVisibility(View.VISIBLE);
}
@Override
@ -101,11 +101,16 @@ public abstract class ProfileActivityDetailsFragment extends Fragment implements
@Override
protected void onPostExecute(ActivityDetails[] result) {
if (pageNumber == 1 && result.length == 0) {
View emptyView = activityList.getEmptyView();
TextView textView = (TextView) emptyView.findViewById(R.id.empty_view_text);
textView.setText(R.string.profile_no_interactions);
}
for (ActivityDetails activity : result) {
adapter.add(activity);
}
adapter.notifyDataSetChanged();
footerProgressView.setVisibility(View.GONE);
loadingProgressView.setVisibility(View.GONE);
}
}.execute();
}