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

@ -234,7 +234,10 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe
list.setAdapter(m_adapter);
list.setOnItemClickListener(this);
registerForContextMenu(list);
View loadingBar = (View) view.findViewById(R.id.feeds_loading_bar);
loadingBar.setVisibility(View.VISIBLE);
//m_activity.m_pullToRefreshAttacher.addRefreshableView(list, this);
return view;
@ -332,7 +335,13 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe
if (list != null) {
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) {
try {

View File

@ -296,14 +296,6 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
@Override
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)) {
return true;
}

View File

@ -31,7 +31,6 @@ import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ListView;
@ -297,7 +296,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
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 (m_enableParentBtn) {
@ -310,19 +309,39 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
} else {
parentBtn.setVisibility(View.GONE);
}
} */
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);
}
ListView list = (ListView)view.findViewById(R.id.feeds);
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.setEmptyView(view.findViewById(R.id.no_feeds));
list.setOnItemClickListener(this);
registerForContextMenu(list);
m_enableFeedIcons = m_prefs.getBoolean("download_feed_icons", false);
//Log.d(TAG, "mpTRA=" + m_activity.m_pullToRefreshAttacher);
View loadingBar = (View) view.findViewById(R.id.feeds_loading_bar);
loadingBar.setVisibility(View.VISIBLE);
//Log.d(TAG, "mpTRA=" + m_activity.m_pullToRefreshAttacher);
//m_activity.m_pullToRefreshAttacher.addRefreshableView(list, this);
return view;
@ -517,7 +536,13 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
if (list != null) {
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);
@ -569,6 +594,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
public static final int VIEW_NORMAL = 0;
public static final int VIEW_SELECTED = 1;
//public static final int VIEW_GOBACK = 2;
public static final int VIEW_COUNT = VIEW_SELECTED+1;
@ -584,8 +610,10 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
@Override
public int getItemViewType(int 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;
} else {
return VIEW_NORMAL;
@ -602,6 +630,8 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
int layoutId = R.layout.feeds_row;
switch (getItemViewType(position)) {
/* case VIEW_GOBACK:
layoutId = R.layout.feeds_goback; */
case VIEW_SELECTED:
layoutId = R.layout.feeds_row_selected;
break;

View File

@ -130,9 +130,6 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
}
switch (item.getItemId()) {
case android.R.id.home:
//getSupportFragmentManager().popBackStack();
return true;
case R.id.headlines_toggle_sort_order:
/* SharedPreferences.Editor editor = m_prefs.edit();
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.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ListView;
@ -172,21 +171,6 @@ public class OfflineFeedsFragment extends Fragment implements OnItemClickListene
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);
m_cursor = createCursor();

View File

@ -4,7 +4,7 @@
android:layout_width="match_parent"
android:layout_height="fill_parent" >
<android.support.v4.widget.SwipeRefreshLayout
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/feeds_swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent" >
@ -29,4 +29,12 @@
android:visibility="invisible" >
</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>

View File

@ -1,15 +1,13 @@
<?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:layout_width="match_parent"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/feeds_swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
android:layout_height="match_parent">
<ListView
android:id="@+id/feeds"
@ -21,15 +19,6 @@
</ListView>
</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
android:id="@+id/no_feeds"
android:layout_width="wrap_content"
@ -40,4 +29,11 @@
android:visibility="gone" >
</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>