add loading progressbars to feeds/cats fragments

replace open parent button with a more familiar to msdos users ".." mnemonic near the listview top
This commit is contained in:
Andrew Dolgov 2014-11-06 19:04:59 +03:00
parent 73cf0c07a6
commit 6be9af4600
8 changed files with 110 additions and 55 deletions

View File

@ -235,6 +235,9 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe
list.setOnItemClickListener(this); list.setOnItemClickListener(this);
registerForContextMenu(list); registerForContextMenu(list);
View loadingBar = (View) view.findViewById(R.id.feeds_loading_bar);
loadingBar.setVisibility(View.VISIBLE);
//m_activity.m_pullToRefreshAttacher.addRefreshableView(list, this); //m_activity.m_pullToRefreshAttacher.addRefreshableView(list, this);
return view; return view;
@ -332,6 +335,12 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe
if (list != null) { if (list != null) {
list.setEmptyView(getView().findViewById(R.id.no_feeds)); list.setEmptyView(getView().findViewById(R.id.no_feeds));
} }
View loadingBar = getView().findViewById(R.id.feeds_loading_bar);
if (loadingBar != null) {
loadingBar.setVisibility(View.GONE);
}
} }
if (result != null) { if (result != null) {

View File

@ -296,14 +296,6 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home && getSupportFragmentManager().getBackStackEntryCount() > 0) {
if (m_drawerLayout != null && m_drawerLayout.isDrawerOpen(Gravity.START)) {
getSupportFragmentManager().popBackStack();
return true;
}
}
if (m_drawerToggle != null && m_drawerToggle.onOptionsItemSelected(item)) { if (m_drawerToggle != null && m_drawerToggle.onOptionsItemSelected(item)) {
return true; return true;
} }

View File

@ -31,7 +31,6 @@ import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ListView; import android.widget.ListView;
@ -297,7 +296,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
android.R.color.holo_orange_dark); android.R.color.holo_orange_dark);
} }
Button parentBtn = (Button) view.findViewById(R.id.open_parent); /* Button parentBtn = (Button) view.findViewById(R.id.open_parent);
if (parentBtn != null) { if (parentBtn != null) {
if (m_enableParentBtn) { if (m_enableParentBtn) {
@ -310,9 +309,26 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
} else { } else {
parentBtn.setVisibility(View.GONE); parentBtn.setVisibility(View.GONE);
} }
} } */
ListView list = (ListView)view.findViewById(R.id.feeds); ListView list = (ListView)view.findViewById(R.id.feeds);
if (m_enableParentBtn) {
View layout = inflater.inflate(R.layout.feeds_goback, container, false);
layout.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT,
ListView.LayoutParams.WRAP_CONTENT));
layout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
m_activity.getSupportFragmentManager().popBackStack();
}
});
list.addHeaderView(layout, null, false);
}
m_adapter = new FeedListAdapter(getActivity(), R.layout.feeds_row, (ArrayList<Feed>)m_feeds); m_adapter = new FeedListAdapter(getActivity(), R.layout.feeds_row, (ArrayList<Feed>)m_feeds);
list.setAdapter(m_adapter); list.setAdapter(m_adapter);
//list.setEmptyView(view.findViewById(R.id.no_feeds)); //list.setEmptyView(view.findViewById(R.id.no_feeds));
@ -322,6 +338,9 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
m_enableFeedIcons = m_prefs.getBoolean("download_feed_icons", false); m_enableFeedIcons = m_prefs.getBoolean("download_feed_icons", false);
View loadingBar = (View) view.findViewById(R.id.feeds_loading_bar);
loadingBar.setVisibility(View.VISIBLE);
//Log.d(TAG, "mpTRA=" + m_activity.m_pullToRefreshAttacher); //Log.d(TAG, "mpTRA=" + m_activity.m_pullToRefreshAttacher);
//m_activity.m_pullToRefreshAttacher.addRefreshableView(list, this); //m_activity.m_pullToRefreshAttacher.addRefreshableView(list, this);
@ -517,6 +536,12 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
if (list != null) { if (list != null) {
list.setEmptyView(getView().findViewById(R.id.no_feeds)); list.setEmptyView(getView().findViewById(R.id.no_feeds));
} }
View loadingBar = getView().findViewById(R.id.feeds_loading_bar);
if (loadingBar != null) {
loadingBar.setVisibility(View.GONE);
}
} }
if (m_swipeLayout != null) m_swipeLayout.setRefreshing(false); if (m_swipeLayout != null) m_swipeLayout.setRefreshing(false);
@ -569,6 +594,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
public static final int VIEW_NORMAL = 0; public static final int VIEW_NORMAL = 0;
public static final int VIEW_SELECTED = 1; public static final int VIEW_SELECTED = 1;
//public static final int VIEW_GOBACK = 2;
public static final int VIEW_COUNT = VIEW_SELECTED+1; public static final int VIEW_COUNT = VIEW_SELECTED+1;
@ -585,7 +611,9 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
public int getItemViewType(int position) { public int getItemViewType(int position) {
Feed feed = items.get(position); Feed feed = items.get(position);
if (m_selectedFeed != null && feed.id == m_selectedFeed.id) { /* if (m_enableParentBtn && position == 0) {
return VIEW_GOBACK;
} else */ if (m_selectedFeed != null && feed.id == m_selectedFeed.id) {
return VIEW_SELECTED; return VIEW_SELECTED;
} else { } else {
return VIEW_NORMAL; return VIEW_NORMAL;
@ -602,6 +630,8 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
int layoutId = R.layout.feeds_row; int layoutId = R.layout.feeds_row;
switch (getItemViewType(position)) { switch (getItemViewType(position)) {
/* case VIEW_GOBACK:
layoutId = R.layout.feeds_goback; */
case VIEW_SELECTED: case VIEW_SELECTED:
layoutId = R.layout.feeds_row_selected; layoutId = R.layout.feeds_row_selected;
break; break;

View File

@ -130,9 +130,6 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
} }
switch (item.getItemId()) { switch (item.getItemId()) {
case android.R.id.home:
//getSupportFragmentManager().popBackStack();
return true;
case R.id.headlines_toggle_sort_order: case R.id.headlines_toggle_sort_order:
/* SharedPreferences.Editor editor = m_prefs.edit(); /* SharedPreferences.Editor editor = m_prefs.edit();
editor.putBoolean("offline_oldest_first", !m_prefs.getBoolean("offline_oldest_first", false)); editor.putBoolean("offline_oldest_first", !m_prefs.getBoolean("offline_oldest_first", false));

View File

@ -25,7 +25,6 @@ import android.view.ViewGroup;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ListView; import android.widget.ListView;
@ -172,21 +171,6 @@ public class OfflineFeedsFragment extends Fragment implements OnItemClickListene
android.R.color.holo_orange_dark); android.R.color.holo_orange_dark);
} }
Button parentBtn = (Button) view.findViewById(R.id.open_parent);
if (parentBtn != null) {
if (m_enableParentBtn) {
parentBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
m_activity.getSupportFragmentManager().popBackStack();
}
});
} else {
parentBtn.setVisibility(View.GONE);
}
}
ListView list = (ListView)view.findViewById(R.id.feeds); ListView list = (ListView)view.findViewById(R.id.feeds);
m_cursor = createCursor(); m_cursor = createCursor();

View File

@ -29,4 +29,12 @@
android:visibility="invisible" > android:visibility="invisible" >
</TextView> </TextView>
<ProgressBar
style="?android:attr/progressBarStyleLarge"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/feeds_loading_bar"
android:layout_gravity="center" />
</FrameLayout> </FrameLayout>

View File

@ -1,15 +1,13 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/feeds_fragment" android:id="@+id/feeds_fragment"
android:layout_width="match_parent" android:layout_width="fill_parent"
android:orientation="vertical"
android:layout_height="fill_parent" > android:layout_height="fill_parent" >
<android.support.v4.widget.SwipeRefreshLayout <android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/feeds_swipe_container" android:id="@+id/feeds_swipe_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
android:layout_weight="1">
<ListView <ListView
android:id="@+id/feeds" android:id="@+id/feeds"
@ -21,15 +19,6 @@
</ListView> </ListView>
</android.support.v4.widget.SwipeRefreshLayout> </android.support.v4.widget.SwipeRefreshLayout>
<Button
style="?android:attr/buttonStyleSmall"
android:background="?parentBtnBackground"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/open_parent"
android:layout_weight="0"
android:id="@+id/open_parent" />
<TextView <TextView
android:id="@+id/no_feeds" android:id="@+id/no_feeds"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -40,4 +29,11 @@
android:visibility="gone" > android:visibility="gone" >
</TextView> </TextView>
</LinearLayout> <ProgressBar
style="?android:attr/progressBarStyleLarge"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/feeds_loading_bar"
android:layout_gravity="center" />
</FrameLayout>

View File

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/feeds_row"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:descendantFocusability="blocksDescendants"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:baselineAligned="true"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:id="@+id/icon"
android:layout_gravity="center_vertical"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_weight="0"
android:scaleType="fitXY"
android:visibility="invisible"
android:src="@drawable/ic_unpublished" />
<TextView
android:fontFamily="sans-serif-light"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_weight="1"
android:ellipsize="end"
android:paddingLeft="16dp"
android:singleLine="true"
android:text=".."
android:paddingBottom="2dp"
android:textColor="?feedlistTextColor"
android:textSize="18sp" />
</LinearLayout>