mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Added favicon to folder row items.
This commit is contained in:
parent
802e42c7a4
commit
bd00207311
4 changed files with 96 additions and 10 deletions
79
media/android/NewsBlur/res/layout/row_folderitem.xml
Normal file
79
media/android/NewsBlur/res/layout/row_folderitem.xml
Normal file
|
@ -0,0 +1,79 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/item_background"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<View
|
||||
android:id="@+id/row_item_favicon_borderbar_1"
|
||||
android:layout_width="8dp"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<View
|
||||
android:id="@+id/row_item_favicon_borderbar_2"
|
||||
android:layout_width="8dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_toRightOf="@id/row_item_favicon_borderbar_1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/row_item_sidebar"
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_toRightOf="@id/row_item_favicon_borderbar_1" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/row_item_feedicon"
|
||||
android:layout_width="21dp"
|
||||
android:layout_height="21dp"
|
||||
android:layout_marginLeft="6dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:background="@drawable/white_background_circle"
|
||||
android:paddingBottom="4dp"
|
||||
android:paddingTop="2dp"
|
||||
android:paddingLeft="2dp"
|
||||
android:paddingRight="2dp"
|
||||
android:layout_toRightOf="@id/row_item_sidebar" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/row_item_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:textColor="@color/darkgray"
|
||||
android:textSize="11dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/row_item_feedtitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_toLeftOf="@id/row_item_date"
|
||||
android:layout_toRightOf="@id/row_item_feedicon"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textColor="@color/darkgray"
|
||||
android:textSize="11dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/row_item_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@id/row_item_feedicon"
|
||||
android:layout_below="@id/row_item_feedicon"
|
||||
android:layout_marginRight="8dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="12dp"
|
||||
android:textColor="@color/darkgray"
|
||||
android:textSize="20dp" />
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -7,25 +7,29 @@ import android.support.v4.widget.SimpleCursorAdapter;
|
|||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.activity.NewsBlurApplication;
|
||||
import com.newsblur.util.AppConstants;
|
||||
import com.newsblur.util.ImageLoader;
|
||||
|
||||
public class SocialFeedItemsAdapter extends SimpleCursorAdapter {
|
||||
|
||||
private Cursor cursor;
|
||||
private Context context;
|
||||
private ImageLoader imageLoader;
|
||||
|
||||
public SocialFeedItemsAdapter(Context context, int layout, Cursor c, String[] from, int[] to, int flags) {
|
||||
super(context, layout, c, from, to, flags);
|
||||
this.context = context;
|
||||
imageLoader = ((NewsBlurApplication) context.getApplicationContext()).getImageLoader();
|
||||
this.cursor = c;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return cursor.getCount();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Cursor swapCursor(Cursor c) {
|
||||
this.cursor = c;
|
||||
|
@ -37,11 +41,14 @@ public class SocialFeedItemsAdapter extends SimpleCursorAdapter {
|
|||
View v = super.getView(position, view, viewGroup);
|
||||
View borderOne = v.findViewById(R.id.row_item_favicon_borderbar_1);
|
||||
View borderTwo = v.findViewById(R.id.row_item_favicon_borderbar_2);
|
||||
|
||||
|
||||
cursor.moveToPosition(position);
|
||||
String feedColour = cursor.getString(cursor.getColumnIndex(DatabaseConstants.FEED_FAVICON_COLOUR));
|
||||
String feedFade = cursor.getString(cursor.getColumnIndex(DatabaseConstants.FEED_FAVICON_FADE));
|
||||
|
||||
String faviconUrl = AppConstants.NEWSBLUR_URL + cursor.getString(cursor.getColumnIndex(DatabaseConstants.FEED_FAVICON_URL));
|
||||
imageLoader.displayImage(faviconUrl, ((ImageView) v.findViewById(R.id.row_item_feedicon)));
|
||||
|
||||
if (!TextUtils.equals(feedColour, "#null") && !TextUtils.equals(feedFade, "#null")) {
|
||||
borderOne.setBackgroundColor(Color.parseColor(feedColour));
|
||||
borderTwo.setBackgroundColor(Color.parseColor(feedFade));
|
||||
|
@ -49,7 +56,7 @@ public class SocialFeedItemsAdapter extends SimpleCursorAdapter {
|
|||
borderOne.setBackgroundColor(Color.GRAY);
|
||||
borderTwo.setBackgroundColor(Color.LTGRAY);
|
||||
}
|
||||
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
|
|
|
@ -88,12 +88,12 @@ public class FolderItemListFragment extends ItemListFragment implements LoaderMa
|
|||
|
||||
Cursor cursor = contentResolver.query(storiesUri, null, FeedProvider.getSelectionFromState(currentState), feedIds, null);
|
||||
|
||||
String[] groupFrom = new String[] { DatabaseConstants.STORY_TITLE, DatabaseConstants.STORY_AUTHORS, DatabaseConstants.STORY_READ, DatabaseConstants.STORY_SHORTDATE, DatabaseConstants.STORY_INTELLIGENCE_AUTHORS };
|
||||
int[] groupTo = new int[] { R.id.row_item_title, R.id.row_item_author, R.id.row_item_title, R.id.row_item_date, R.id.row_item_sidebar };
|
||||
String[] groupFrom = new String[] { DatabaseConstants.STORY_TITLE, DatabaseConstants.FEED_TITLE, DatabaseConstants.STORY_READ, DatabaseConstants.STORY_SHORTDATE, DatabaseConstants.STORY_INTELLIGENCE_AUTHORS };
|
||||
int[] groupTo = new int[] { R.id.row_item_title, R.id.row_item_feedtitle, R.id.row_item_title, R.id.row_item_date, R.id.row_item_sidebar };
|
||||
|
||||
getLoaderManager().initLoader(ITEMLIST_LOADER , null, this);
|
||||
|
||||
adapter = new SocialFeedItemsAdapter(getActivity(), R.layout.row_item, cursor, groupFrom, groupTo, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
|
||||
adapter = new SocialFeedItemsAdapter(getActivity(), R.layout.row_folderitem, cursor, groupFrom, groupTo, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
|
||||
|
||||
itemList.setOnScrollListener(this);
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ public class SocialItemViewBinder implements ViewBinder {
|
|||
} else {
|
||||
view.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else if (TextUtils.equals(cursor.getColumnName(columnIndex), DatabaseConstants.FEED_FAVICON_URL)) {
|
||||
} else if (TextUtils.equals(cursor.getColumnName(columnIndex), DatabaseConstants.FEED_FAVICON_URL)) {
|
||||
String faviconUrl = AppConstants.NEWSBLUR_URL + cursor.getString(columnIndex);
|
||||
imageLoader.displayImage(faviconUrl, ((ImageView) view));
|
||||
return true;
|
||||
|
|
Loading…
Add table
Reference in a new issue