Bug fixes - Implemented an background delay timer which syncs the state
of the items each 30 seconds.
This commit is contained in:
parent
c2fdb8550e
commit
7d89f22195
23 changed files with 756 additions and 730 deletions
68
.project
68
.project
|
@ -1,33 +1,35 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>OwncloudNewsReader</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>OwncloudNewsReader</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
<project>ActionBarSherlock</project>
|
||||
<project>Android-PullToRefresh</project>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
|
|
|
@ -1,54 +1,55 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="de.luhmer.owncloudnewsreader"
|
||||
android:versionCode="21"
|
||||
android:versionName="0.3.8" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="7"
|
||||
android:targetSdkVersion="17" />
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="com.android.vending.BILLING" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name="de.luhmer.owncloudnewsreader.NewsReaderListActivity"
|
||||
android:label="@string/app_name" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name="de.luhmer.owncloudnewsreader.NewsReaderDetailActivity"
|
||||
android:label="@string/title_newsreader_detail"
|
||||
android:parentActivityName=".NewsReaderListActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" >
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".NewsReaderListActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name="de.luhmer.owncloudnewsreader.NewsDetailActivity"
|
||||
android:label="@string/title_activity_news_detail"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" >
|
||||
</activity>
|
||||
|
||||
<service android:name="de.luhmer.owncloudnewsreader.services.SyncService" />
|
||||
<service android:name="de.luhmer.owncloudnewsreader.services.DownloadImagesService" />
|
||||
|
||||
<activity
|
||||
android:name="de.luhmer.owncloudnewsreader.SettingsActivity"
|
||||
android:label="@string/title_activity_settings" >
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="de.luhmer.owncloudnewsreader"
|
||||
android:versionCode="22"
|
||||
android:versionName="0.3.9" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="7"
|
||||
android:targetSdkVersion="17" />
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="com.android.vending.BILLING" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name="de.luhmer.owncloudnewsreader.NewsReaderListActivity"
|
||||
android:label="@string/app_name" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name="de.luhmer.owncloudnewsreader.NewsReaderDetailActivity"
|
||||
android:label="@string/title_newsreader_detail"
|
||||
android:parentActivityName=".NewsReaderListActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" >
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".NewsReaderListActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name="de.luhmer.owncloudnewsreader.NewsDetailActivity"
|
||||
android:label="@string/title_activity_news_detail"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" >
|
||||
</activity>
|
||||
|
||||
<service android:name="de.luhmer.owncloudnewsreader.services.SyncService" />
|
||||
<service android:name="de.luhmer.owncloudnewsreader.services.DownloadImagesService" />
|
||||
<service android:name="de.luhmer.owncloudnewsreader.services.SyncItemStateService" />
|
||||
|
||||
<activity
|
||||
android:name="de.luhmer.owncloudnewsreader.SettingsActivity"
|
||||
android:label="@string/title_activity_settings" >
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
|
@ -12,5 +12,6 @@
|
|||
|
||||
# Project target.
|
||||
target=android-17
|
||||
android.library.reference.1=..\\..\\workspace_juno\\actionbarsherlock
|
||||
android.library.reference.1=../ActionBarSherlock/actionbarsherlock
|
||||
android.library.reference.2=../Android-PullToRefresh/library
|
||||
android.library.reference.3=../AndroidPinning
|
||||
|
|
|
@ -1,25 +1,34 @@
|
|||
package de.luhmer.owncloudnewsreader;
|
||||
|
||||
public class Constants {
|
||||
public static final Boolean DEBUG_MODE = true;
|
||||
|
||||
public static final String UPDATE_SERVER_HOSTNAME = "https://ourhomework.de/N43Z5W5T6721903JS98SFD7";
|
||||
public static final String FILENAME = "OwncloudNewsReader.apk";
|
||||
|
||||
public static final String _TAG_LABEL_UNREAD = "stream/contents/user/-/state/com.google/reading-list?n=1000&r=n&xt=user/-/state/com.google/read";
|
||||
public static final String _TAG_LABEL_STARRED = "stream/contents/user/-/state/com.google/starred?n=20";
|
||||
|
||||
public static final String LAST_SYNC = "LAST_SYNC";
|
||||
|
||||
|
||||
private static final String _P_KEY_PART1 = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgNmCsMj6M4zkjpKRG8MG5+yIAyqSQE2etVkZsc3s";
|
||||
private static final String _P_KEY_PART2 = "V5zLoQ/NUOVC0fS2tj8IWk6UYqQGk9rmVold3sDGiTCvWGFecjwel3qxzz23hKLlemrv2+0WPrZ5KOqiaCEMi";
|
||||
private static final String _P_KEY_PART3 = "CeQ7zgpcytcQdD9Y/aeaHJ9P27ntn0ub6H1Bx3VDRHm4Jkg6LQnqmdIpEmeIztnoMFlLXTaVKapaFmqJGX9ar";
|
||||
private static final String _P_KEY_PART4 = "RizGd9kqtgAqIP7YnGGDV1vP/MqYpegJkOMOlxhuVvXUsg7t7hBLdGXsJ572DzUK/2/fbZ+PIcG7OF4RgJV7Yb";
|
||||
private static final String _P_KEY_PART5 = "/AVD0ssqydMlwuheOG82FCqhBtw2vShAz7mkWgL0l0u5HQIDAQAB";
|
||||
|
||||
public static String getBase64EncodedPublicKey()
|
||||
{
|
||||
return _P_KEY_PART1 + _P_KEY_PART2 + _P_KEY_PART3 + _P_KEY_PART4 + _P_KEY_PART5;
|
||||
}
|
||||
}
|
||||
package de.luhmer.owncloudnewsreader;
|
||||
|
||||
public class Constants {
|
||||
public static final Boolean DEBUG_MODE = true;
|
||||
|
||||
public static final String UPDATE_SERVER_HOSTNAME = "https://ourhomework.de/N43Z5W5T6721903JS98SFD7";
|
||||
public static final String FILENAME = "OwncloudNewsReader.apk";
|
||||
|
||||
public static final String _TAG_LABEL_UNREAD = "stream/contents/user/-/state/com.google/reading-list?n=1000&r=n&xt=user/-/state/com.google/read";
|
||||
public static final String _TAG_LABEL_STARRED = "stream/contents/user/-/state/com.google/starred?n=20";
|
||||
|
||||
public static final String LAST_SYNC = "LAST_SYNC";
|
||||
|
||||
public static final int maxItemsCount = 1000;
|
||||
|
||||
|
||||
public static final int TaskID_GetVersion = -10;
|
||||
public static final int TaskID_GetFolder = 1;
|
||||
public static final int TaskID_GetFeeds = 2;
|
||||
public static final int TaskID_GetItems = 3;
|
||||
public static final int TaskID_PerformStateChange = -1;
|
||||
|
||||
|
||||
private static final String _P_KEY_PART1 = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgNmCsMj6M4zkjpKRG8MG5+yIAyqSQE2etVkZsc3s";
|
||||
private static final String _P_KEY_PART2 = "V5zLoQ/NUOVC0fS2tj8IWk6UYqQGk9rmVold3sDGiTCvWGFecjwel3qxzz23hKLlemrv2+0WPrZ5KOqiaCEMi";
|
||||
private static final String _P_KEY_PART3 = "CeQ7zgpcytcQdD9Y/aeaHJ9P27ntn0ub6H1Bx3VDRHm4Jkg6LQnqmdIpEmeIztnoMFlLXTaVKapaFmqJGX9ar";
|
||||
private static final String _P_KEY_PART4 = "RizGd9kqtgAqIP7YnGGDV1vP/MqYpegJkOMOlxhuVvXUsg7t7hBLdGXsJ572DzUK/2/fbZ+PIcG7OF4RgJV7Yb";
|
||||
private static final String _P_KEY_PART5 = "/AVD0ssqydMlwuheOG82FCqhBtw2vShAz7mkWgL0l0u5HQIDAQAB";
|
||||
|
||||
public static String getBase64EncodedPublicKey()
|
||||
{
|
||||
return _P_KEY_PART1 + _P_KEY_PART2 + _P_KEY_PART3 + _P_KEY_PART4 + _P_KEY_PART5;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,453 +1,450 @@
|
|||
package de.luhmer.owncloudnewsreader.ListView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.SparseArray;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseExpandableListAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import de.luhmer.owncloudnewsreader.R;
|
||||
import de.luhmer.owncloudnewsreader.SettingsActivity;
|
||||
import de.luhmer.owncloudnewsreader.async_tasks.FillTextForTextViewAsyncTask;
|
||||
import de.luhmer.owncloudnewsreader.async_tasks.IGetTextForTextViewAsyncTask;
|
||||
import de.luhmer.owncloudnewsreader.data.AbstractItem;
|
||||
import de.luhmer.owncloudnewsreader.data.ConcreteSubscribtionItem;
|
||||
import de.luhmer.owncloudnewsreader.data.FolderSubscribtionItem;
|
||||
import de.luhmer.owncloudnewsreader.database.DatabaseConnection;
|
||||
import de.luhmer.owncloudnewsreader.helper.FavIconHandler;
|
||||
import de.luhmer.owncloudnewsreader.helper.ThemeChooser;
|
||||
import de.luhmer.owncloudnewsreader.interfaces.ExpListTextClicked;
|
||||
|
||||
public class SubscriptionExpandableListAdapter extends BaseExpandableListAdapter {
|
||||
|
||||
private Context mContext;
|
||||
private DatabaseConnection dbConn;
|
||||
|
||||
ExpListTextClicked eListTextClickHandler;
|
||||
|
||||
private ArrayList<FolderSubscribtionItem> mCategoriesArrayList;
|
||||
private SparseArray<SparseArray<ConcreteSubscribtionItem>> mItemsArrayList;
|
||||
private boolean showOnlyUnread = false;
|
||||
|
||||
public static final String ALL_UNREAD_ITEMS = "-10";
|
||||
public static final String ALL_STARRED_ITEMS = "-11";
|
||||
public static final String ITEMS_WITHOUT_FOLDER = "-22";
|
||||
|
||||
|
||||
public SubscriptionExpandableListAdapter(Context mContext, DatabaseConnection dbConn)
|
||||
{
|
||||
this.mContext = mContext;
|
||||
this.dbConn = dbConn;
|
||||
|
||||
ReloadAdapter();
|
||||
}
|
||||
|
||||
private void AddEverythingInCursorFolderToSubscriptions(Cursor itemsCursor)
|
||||
{
|
||||
while (itemsCursor.moveToNext()) {
|
||||
String header = itemsCursor.getString(itemsCursor.getColumnIndex(DatabaseConnection.FOLDER_LABEL));
|
||||
//String id_folder = itemsCursor.getString(itemsCursor.getColumnIndex(DatabaseConnection.FOLDER_LABEL_ID));
|
||||
long id = itemsCursor.getLong(0);
|
||||
mCategoriesArrayList.add(new FolderSubscribtionItem(header, null, id));
|
||||
}
|
||||
itemsCursor.close();
|
||||
}
|
||||
|
||||
private void AddEverythingInCursorFeedsToSubscriptions(Cursor itemsCursor)
|
||||
{
|
||||
while (itemsCursor.moveToNext()) {
|
||||
String header = itemsCursor.getString(itemsCursor.getColumnIndex(DatabaseConnection.SUBSCRIPTION_HEADERTEXT));
|
||||
//String id_folder = itemsCursor.getString(itemsCursor.getColumnIndex(DatabaseConnection.SUBSCRIPTION_ID));
|
||||
long id = itemsCursor.getLong(0);
|
||||
mCategoriesArrayList.add(new FolderSubscribtionItem(header, ITEMS_WITHOUT_FOLDER, id));
|
||||
}
|
||||
itemsCursor.close();
|
||||
}
|
||||
|
||||
/*
|
||||
private String getUnreadTextFolder(String id_db_folder, boolean onlyUnread)
|
||||
{
|
||||
//return dbConn.getCountFeedsForFolder(id_db_folder, onlyUnread) + "/" + dbConn.getCountFeedsForFolder(id_db_folder, !onlyUnread);
|
||||
return convertCountIntToString(dbConn.getCountFeedsForFolder(id_db_folder, onlyUnread));
|
||||
}
|
||||
|
||||
private String getUnreadTextItems(String id_db_item, boolean onlyUnread, boolean execludeStarredItems)
|
||||
{
|
||||
//return dbConn.getCountItemsForSubscription(id_db_item, onlyUnread, execludeStarredItems) + "/" + dbConn.getCountItemsForSubscription(id_db_item, !onlyUnread, execludeStarredItems);
|
||||
return convertCountIntToString(dbConn.getCountItemsForSubscription(id_db_item, onlyUnread, execludeStarredItems));
|
||||
}*/
|
||||
|
||||
/*
|
||||
private String convertCountIntToString(int value)
|
||||
{
|
||||
if(value > 0)
|
||||
return String.valueOf(value);
|
||||
else
|
||||
return "";
|
||||
|
||||
}*/
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public Object getChild(int groupPosition, int childPosition) {
|
||||
int parent_id = (int)getGroupId(groupPosition);
|
||||
//Check if we are not in our current group now, or the current cached items are wrong - MUST BE RECACHED
|
||||
//if(mItemsArrayList.isEmpty() /*|| ((ConcreteSubscribtionItem)mItemsArrayList.get(0)).parent_id != parent_id */){
|
||||
if(mItemsArrayList.indexOfKey(groupPosition) < 0 /*|| (mItemsArrayList.get(groupPosition).size() <= childPosition)*/ /*|| ((ConcreteSubscribtionItem)mItemsArrayList.get(0)).parent_id != parent_id */){
|
||||
mItemsArrayList.append(groupPosition, new SparseArray<ConcreteSubscribtionItem>());
|
||||
Cursor itemsCursor = dbConn.getAllSubscriptionForFolder(String.valueOf(parent_id), showOnlyUnread);
|
||||
itemsCursor.requery();
|
||||
//mItemsArrayList.clear();
|
||||
int childPosTemp = childPosition;
|
||||
if (itemsCursor.moveToFirst())
|
||||
do {
|
||||
long id_database = itemsCursor.getLong(0);
|
||||
String name = itemsCursor.getString(1);
|
||||
String subscription_id = itemsCursor.getString(2);
|
||||
String urlFavicon = itemsCursor.getString(itemsCursor.getColumnIndex(DatabaseConnection.SUBSCRIPTION_FAVICON_URL));
|
||||
ConcreteSubscribtionItem newItem = new ConcreteSubscribtionItem(name, String.valueOf(parent_id), subscription_id, urlFavicon, id_database);
|
||||
mItemsArrayList.get(groupPosition).put(childPosTemp, newItem);
|
||||
childPosTemp++;
|
||||
} while (itemsCursor.moveToNext());
|
||||
itemsCursor.close();
|
||||
}
|
||||
return mItemsArrayList.get(groupPosition).get(childPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getChildId(int groupPosition, int childPosition) {
|
||||
return ((ConcreteSubscribtionItem)(getChild(groupPosition, childPosition))).id_database;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getChildView(int groupPosition, int childPosition,
|
||||
boolean isLastChild, View convertView, ViewGroup parent) {
|
||||
LinearLayout view;
|
||||
|
||||
ConcreteSubscribtionItem item = (ConcreteSubscribtionItem)getChild(groupPosition, childPosition);
|
||||
|
||||
if (convertView == null) {
|
||||
view = new LinearLayout(mContext);
|
||||
String inflater = Context.LAYOUT_INFLATER_SERVICE;
|
||||
LayoutInflater vi = (LayoutInflater) mContext.getSystemService(inflater);
|
||||
vi.inflate(R.layout.subscription_list_sub_item, view, true);
|
||||
if(item != null)
|
||||
view.setTag(item.id_database);
|
||||
} else {
|
||||
view = (LinearLayout) convertView;
|
||||
}
|
||||
|
||||
if(item != null)
|
||||
{
|
||||
TextView textTV = (TextView) view.findViewById(R.id.summary);
|
||||
String headerText = (item.header != null) ? item.header : "";
|
||||
textTV.setText(headerText);
|
||||
|
||||
boolean execludeStarredItems = (item.folder_id.equals(ALL_STARRED_ITEMS)) ? false : true;
|
||||
|
||||
TextView tV_UnreadCount = (TextView) view.findViewById(R.id.tv_unreadCount);
|
||||
//String unread = dbConn.getCountItemsForSubscription(String.valueOf(item.id_database), true, execludeStarredItems);
|
||||
//String total = dbConn.getCountItemsForSubscription(String.valueOf(item.id_database), false, execludeStarredItems);
|
||||
//tV_UnreadCount.setText(unread + "/" + total);
|
||||
//tV_UnreadCount.setText(getUnreadTextItems(String.valueOf(item.id_database), false, execludeStarredItems));
|
||||
tV_UnreadCount.setText("");
|
||||
SetUnreadCountForFeed(tV_UnreadCount, String.valueOf(item.id_database), execludeStarredItems);
|
||||
|
||||
ImageView imgView = (ImageView) view.findViewById(R.id.iVFavicon);
|
||||
GetFavIconForFeed(item.favIcon, imgView);
|
||||
}
|
||||
else
|
||||
{
|
||||
TextView textTV = (TextView) view.findViewById(R.id.summary);
|
||||
textTV.setText("Sorry, something went wrong here :(");
|
||||
|
||||
TextView tV_UnreadCount = (TextView) view.findViewById(R.id.tv_unreadCount);
|
||||
tV_UnreadCount.setText("0");
|
||||
|
||||
ImageView imgView = (ImageView) view.findViewById(R.id.iVFavicon);
|
||||
imgView.setImageDrawable(null);
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChildrenCount(int groupPosition) {
|
||||
int count;
|
||||
if(mItemsArrayList.indexOfKey(groupPosition) < 0){
|
||||
Cursor itemsCursor = dbConn.getAllSubscriptionForFolder(String.valueOf(getGroupId(groupPosition)), showOnlyUnread);
|
||||
count = itemsCursor.getCount();
|
||||
itemsCursor.close();
|
||||
}
|
||||
else
|
||||
count = mItemsArrayList.get(groupPosition).size();
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getGroup(int groupPosition) {
|
||||
return mCategoriesArrayList.get(groupPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupCount() {
|
||||
return mCategoriesArrayList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getGroupId(int groupPosition) {
|
||||
return ((AbstractItem)getGroup(groupPosition)).id_database;
|
||||
}
|
||||
|
||||
@SuppressLint("CutPasteId")
|
||||
@Override
|
||||
public View getGroupView(int groupPosition, boolean isExpanded,
|
||||
View convertView, ViewGroup parent) {
|
||||
LinearLayout view;
|
||||
//View view;
|
||||
GroupHolder viewHolder;
|
||||
|
||||
final FolderSubscribtionItem group = (FolderSubscribtionItem)getGroup(groupPosition);
|
||||
|
||||
if (convertView == null) {
|
||||
view = new LinearLayout(mContext);
|
||||
String inflater = Context.LAYOUT_INFLATER_SERVICE;
|
||||
LayoutInflater vi = (LayoutInflater) mContext.getSystemService(inflater);
|
||||
vi.inflate(R.layout.subscription_list_item, view, true);
|
||||
|
||||
ImageView indicatorImage = (ImageView) view.findViewById(R.id.img_View_expandable_indicator);
|
||||
TextView txt_Summary = (TextView) view.findViewById(R.id.summary);
|
||||
TextView textFeedCount = (TextView) view.findViewById(R.id.tV_feedsCount);
|
||||
|
||||
viewHolder = new GroupHolder();
|
||||
viewHolder.imgView = indicatorImage;
|
||||
viewHolder.txt_Summary = txt_Summary;
|
||||
viewHolder.txt_UnreadCount = textFeedCount;
|
||||
|
||||
viewHolder.txt_Summary.setClickable(true);
|
||||
|
||||
view.setTag(viewHolder);
|
||||
//view = convertView;
|
||||
convertView = view;
|
||||
|
||||
} else {
|
||||
view = (LinearLayout) convertView;
|
||||
viewHolder = (GroupHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
|
||||
viewHolder.txt_Summary.setText(group.headerFolder);
|
||||
viewHolder.txt_Summary.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//v.setPressed(true);
|
||||
//v.setSelected(true);
|
||||
//v.setBackgroundColor(mContext.getResources().getColor(android.R.color.holo_blue_light));
|
||||
//NewsReaderActivity.StartSubscriptionActivity((View) v.getParent().getParent(), mContext);
|
||||
//v.setBackgroundColor(mContext.getResources().getColor(android.R.color.transparent));
|
||||
//group.id;
|
||||
//ExpandableListView exListView = ((ExpandableListView) v.getParent().getParent().getParent());
|
||||
//exListView.setEmptyView(tView);
|
||||
//exListView.getSelectedPosition();
|
||||
|
||||
//String val = String.valueOf(((View) v.getParent().getParent()).getTag());
|
||||
String val = String.valueOf(group.id_database /*((LinearLayout) v.getParent()).getChildAt(1).getTag()*/);
|
||||
boolean skipFireEvent = false;
|
||||
if(group.idFolder != null)
|
||||
{
|
||||
if(group.idFolder.equals(ITEMS_WITHOUT_FOLDER))
|
||||
{
|
||||
fireListTextClicked(val, mContext, false, group.idFolder);
|
||||
skipFireEvent = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!skipFireEvent)
|
||||
fireListTextClicked(val, mContext, true, group.idFolder);
|
||||
}
|
||||
});
|
||||
/*
|
||||
if(viewHolder.txt_UnreadCount.getText() == "")
|
||||
{
|
||||
String unreadCountText = null;
|
||||
boolean skipGetUnread = false;
|
||||
if(group.idFolder != null)
|
||||
{
|
||||
if(group.idFolder.equals(ITEMS_WITHOUT_FOLDER))
|
||||
{
|
||||
unreadCountText = dbConn.getCountItemsForSubscription(String.valueOf(group.id_database), true, true) + "/" + dbConn.getCountItemsForSubscription(String.valueOf(group.id_database), false, true);
|
||||
skipGetUnread = true;
|
||||
}
|
||||
}
|
||||
if(!skipGetUnread)
|
||||
unreadCountText = dbConn.getCountFeedsForFolder(String.valueOf(group.id_database), true) + "/" + dbConn.getCountFeedsForFolder(String.valueOf(group.id_database), false);
|
||||
|
||||
viewHolder.txt_UnreadCount.setText(unreadCountText);
|
||||
}*/
|
||||
|
||||
boolean skipGetUnread = false;
|
||||
if(group.idFolder != null)
|
||||
{
|
||||
if(group.idFolder.equals(ITEMS_WITHOUT_FOLDER))
|
||||
{
|
||||
//unreadCountText = getUnreadTextItems(String.valueOf(group.id_database), true, true);
|
||||
SetUnreadCountForFeed(viewHolder.txt_UnreadCount, String.valueOf(group.id_database), true);
|
||||
skipGetUnread = true;
|
||||
}
|
||||
}
|
||||
if(!skipGetUnread)
|
||||
SetUnreadCountForFolder(viewHolder.txt_UnreadCount, String.valueOf(group.id_database), true);
|
||||
//unreadCountText = getUnreadTextFolder(String.valueOf(group.id_database), true);
|
||||
|
||||
|
||||
viewHolder.txt_UnreadCount.setText("");
|
||||
|
||||
|
||||
//viewHolder.txt_UnreadCount.setText(group.unreadCount);
|
||||
|
||||
if(group.idFolder != null)
|
||||
{
|
||||
if(group.idFolder.equals(ITEMS_WITHOUT_FOLDER))
|
||||
{
|
||||
Cursor cursor = dbConn.getFeedByDbID(String.valueOf(group.id_database));
|
||||
if(cursor != null)
|
||||
{
|
||||
if(cursor.getCount() > 0)
|
||||
{
|
||||
cursor.moveToFirst();
|
||||
String favIconURL = cursor.getString(cursor.getColumnIndex(DatabaseConnection.SUBSCRIPTION_FAVICON_URL));
|
||||
GetFavIconForFeed(favIconURL, viewHolder.imgView);
|
||||
}
|
||||
}
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(String.valueOf(group.id_database).equals(ALL_STARRED_ITEMS))
|
||||
{
|
||||
viewHolder.imgView.setVisibility( View.VISIBLE );
|
||||
viewHolder.imgView.setImageResource(R.drawable.star);
|
||||
} else if (getChildrenCount( groupPosition ) == 0 ) {
|
||||
viewHolder.imgView.setVisibility( View.INVISIBLE );
|
||||
//viewHolder.imgView.setImageDrawable(null);
|
||||
}
|
||||
else {
|
||||
viewHolder.imgView.setVisibility( View.VISIBLE );
|
||||
if(ThemeChooser.isDarkTheme(mContext))
|
||||
viewHolder.imgView.setImageResource( isExpanded ? R.drawable.ic_find_previous_holo_dark : R.drawable.ic_find_next_holo_dark);
|
||||
else
|
||||
viewHolder.imgView.setImageResource( isExpanded ? R.drawable.ic_find_previous_holo_light : R.drawable.ic_find_next_holo_light);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//view.setTag(group.id_database);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
private void SetUnreadCountForFeed(TextView textView, String idDatabase, boolean execludeStarredItems)
|
||||
{
|
||||
IGetTextForTextViewAsyncTask iGetter = new UnreadFeedCount(mContext, idDatabase, execludeStarredItems);
|
||||
new FillTextForTextViewAsyncTask(textView, iGetter).execute((Void) null);
|
||||
}
|
||||
|
||||
private void SetUnreadCountForFolder(TextView textView, String idDatabase, boolean execludeStarredItems)
|
||||
{
|
||||
IGetTextForTextViewAsyncTask iGetter = new UnreadFolderCount(mContext, idDatabase);
|
||||
new FillTextForTextViewAsyncTask(textView, iGetter).execute((Void) null);
|
||||
}
|
||||
|
||||
private void GetFavIconForFeed(String favIconURL, ImageView imgView)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(favIconURL != null)
|
||||
{
|
||||
|
||||
if(favIconURL.trim().length() > 0)
|
||||
{
|
||||
FavIconHandler.GetImageAsync(imgView, favIconURL, mContext);
|
||||
//new FavIconHandler.GetImageFromWebAsyncTask(favIconURL, mContext, imgView).execute((Void)null);
|
||||
}
|
||||
else
|
||||
imgView.setImageResource(FavIconHandler.getResourceIdForRightDefaultFeedIcon(mContext));
|
||||
}
|
||||
else
|
||||
imgView.setImageResource(FavIconHandler.getResourceIdForRightDefaultFeedIcon(mContext));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
static class GroupHolder
|
||||
{
|
||||
TextView txt_Summary;
|
||||
TextView txt_UnreadCount;
|
||||
ImageView imgView;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasStableIds() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChildSelectable(int groupPosition, int childPosition) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public void registerDataSetObserver(DataSetObserver observer) {
|
||||
//used to make the notifyDataSetChanged() method work
|
||||
super.registerDataSetObserver(observer);
|
||||
}*/
|
||||
|
||||
public void ReloadAdapter()
|
||||
{
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(mContext);
|
||||
showOnlyUnread = mPrefs.getBoolean(SettingsActivity.CB_SHOWONLYUNREAD_STRING, false);
|
||||
|
||||
mCategoriesArrayList = new ArrayList<FolderSubscribtionItem>();
|
||||
mCategoriesArrayList.add(new FolderSubscribtionItem(mContext.getString(R.string.allUnreadFeeds), null, Long.valueOf(ALL_UNREAD_ITEMS)));
|
||||
mCategoriesArrayList.add(new FolderSubscribtionItem(mContext.getString(R.string.starredFeeds), null, Long.valueOf(ALL_STARRED_ITEMS)));
|
||||
|
||||
//mCategoriesArrayList.add(new FolderSubscribtionItem(mContext.getString(R.string.starredFeeds), -11, null, null));
|
||||
|
||||
AddEverythingInCursorFolderToSubscriptions(dbConn.getAllTopSubscriptions(showOnlyUnread));
|
||||
AddEverythingInCursorFeedsToSubscriptions(dbConn.getAllTopSubscriptionsWithoutFolder(showOnlyUnread));
|
||||
|
||||
//AddEverythingInCursorToSubscriptions(dbConn.getAllTopSubscriptionsWithUnreadFeeds());
|
||||
mItemsArrayList = new SparseArray<SparseArray<ConcreteSubscribtionItem>>();
|
||||
|
||||
this.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
||||
public void setHandlerListener(ExpListTextClicked listener)
|
||||
{
|
||||
eListTextClickHandler = listener;
|
||||
}
|
||||
protected void fireListTextClicked(String idSubscription, Context context, boolean isFolder, String optional_folder_id)
|
||||
{
|
||||
if(eListTextClickHandler != null)
|
||||
eListTextClickHandler.onTextClicked(idSubscription, context, isFolder, optional_folder_id);
|
||||
}
|
||||
package de.luhmer.owncloudnewsreader.ListView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.SparseArray;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseExpandableListAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import de.luhmer.owncloudnewsreader.R;
|
||||
import de.luhmer.owncloudnewsreader.SettingsActivity;
|
||||
import de.luhmer.owncloudnewsreader.async_tasks.FillTextForTextViewAsyncTask;
|
||||
import de.luhmer.owncloudnewsreader.async_tasks.IGetTextForTextViewAsyncTask;
|
||||
import de.luhmer.owncloudnewsreader.data.AbstractItem;
|
||||
import de.luhmer.owncloudnewsreader.data.ConcreteFeedItem;
|
||||
import de.luhmer.owncloudnewsreader.data.FolderSubscribtionItem;
|
||||
import de.luhmer.owncloudnewsreader.database.DatabaseConnection;
|
||||
import de.luhmer.owncloudnewsreader.helper.FavIconHandler;
|
||||
import de.luhmer.owncloudnewsreader.helper.ThemeChooser;
|
||||
import de.luhmer.owncloudnewsreader.interfaces.ExpListTextClicked;
|
||||
|
||||
public class SubscriptionExpandableListAdapter extends BaseExpandableListAdapter {
|
||||
|
||||
private Context mContext;
|
||||
private DatabaseConnection dbConn;
|
||||
|
||||
ExpListTextClicked eListTextClickHandler;
|
||||
|
||||
private ArrayList<FolderSubscribtionItem> mCategoriesArrayList;
|
||||
private SparseArray<SparseArray<ConcreteFeedItem>> mItemsArrayList;
|
||||
private boolean showOnlyUnread = false;
|
||||
|
||||
public static final String ALL_UNREAD_ITEMS = "-10";
|
||||
public static final String ALL_STARRED_ITEMS = "-11";
|
||||
public static final String ITEMS_WITHOUT_FOLDER = "-22";
|
||||
|
||||
|
||||
public SubscriptionExpandableListAdapter(Context mContext, DatabaseConnection dbConn)
|
||||
{
|
||||
this.mContext = mContext;
|
||||
this.dbConn = dbConn;
|
||||
|
||||
ReloadAdapter();
|
||||
}
|
||||
|
||||
private void AddEverythingInCursorFolderToSubscriptions(Cursor itemsCursor)
|
||||
{
|
||||
while (itemsCursor.moveToNext()) {
|
||||
String header = itemsCursor.getString(itemsCursor.getColumnIndex(DatabaseConnection.FOLDER_LABEL));
|
||||
//String id_folder = itemsCursor.getString(itemsCursor.getColumnIndex(DatabaseConnection.FOLDER_LABEL_ID));
|
||||
long id = itemsCursor.getLong(0);
|
||||
mCategoriesArrayList.add(new FolderSubscribtionItem(header, null, id));
|
||||
}
|
||||
itemsCursor.close();
|
||||
}
|
||||
|
||||
private void AddEverythingInCursorFeedsToSubscriptions(Cursor itemsCursor)
|
||||
{
|
||||
while (itemsCursor.moveToNext()) {
|
||||
String header = itemsCursor.getString(itemsCursor.getColumnIndex(DatabaseConnection.SUBSCRIPTION_HEADERTEXT));
|
||||
//String id_folder = itemsCursor.getString(itemsCursor.getColumnIndex(DatabaseConnection.SUBSCRIPTION_ID));
|
||||
long id = itemsCursor.getLong(0);
|
||||
mCategoriesArrayList.add(new FolderSubscribtionItem(header, ITEMS_WITHOUT_FOLDER, id));
|
||||
}
|
||||
itemsCursor.close();
|
||||
}
|
||||
|
||||
/*
|
||||
private String getUnreadTextFolder(String id_db_folder, boolean onlyUnread)
|
||||
{
|
||||
//return dbConn.getCountFeedsForFolder(id_db_folder, onlyUnread) + "/" + dbConn.getCountFeedsForFolder(id_db_folder, !onlyUnread);
|
||||
return convertCountIntToString(dbConn.getCountFeedsForFolder(id_db_folder, onlyUnread));
|
||||
}
|
||||
|
||||
private String getUnreadTextItems(String id_db_item, boolean onlyUnread, boolean execludeStarredItems)
|
||||
{
|
||||
//return dbConn.getCountItemsForSubscription(id_db_item, onlyUnread, execludeStarredItems) + "/" + dbConn.getCountItemsForSubscription(id_db_item, !onlyUnread, execludeStarredItems);
|
||||
return convertCountIntToString(dbConn.getCountItemsForSubscription(id_db_item, onlyUnread, execludeStarredItems));
|
||||
}*/
|
||||
|
||||
/*
|
||||
private String convertCountIntToString(int value)
|
||||
{
|
||||
if(value > 0)
|
||||
return String.valueOf(value);
|
||||
else
|
||||
return "";
|
||||
|
||||
}*/
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public Object getChild(int groupPosition, int childPosition) {
|
||||
int parent_id = (int)getGroupId(groupPosition);
|
||||
//Check if we are not in our current group now, or the current cached items are wrong - MUST BE RECACHED
|
||||
//if(mItemsArrayList.isEmpty() /*|| ((ConcreteSubscribtionItem)mItemsArrayList.get(0)).parent_id != parent_id */){
|
||||
if(mItemsArrayList.indexOfKey(groupPosition) < 0 /*|| (mItemsArrayList.get(groupPosition).size() <= childPosition)*/ /*|| ((ConcreteSubscribtionItem)mItemsArrayList.get(0)).parent_id != parent_id */){
|
||||
mItemsArrayList.append(groupPosition, new SparseArray<ConcreteFeedItem>());
|
||||
Cursor itemsCursor = dbConn.getAllSubscriptionForFolder(String.valueOf(parent_id), showOnlyUnread);
|
||||
itemsCursor.requery();
|
||||
//mItemsArrayList.clear();
|
||||
int childPosTemp = childPosition;
|
||||
if (itemsCursor.moveToFirst())
|
||||
do {
|
||||
long id_database = itemsCursor.getLong(0);
|
||||
String name = itemsCursor.getString(1);
|
||||
String subscription_id = itemsCursor.getString(2);
|
||||
String urlFavicon = itemsCursor.getString(itemsCursor.getColumnIndex(DatabaseConnection.SUBSCRIPTION_FAVICON_URL));
|
||||
ConcreteFeedItem newItem = new ConcreteFeedItem(name, String.valueOf(parent_id), subscription_id, urlFavicon, id_database);
|
||||
mItemsArrayList.get(groupPosition).put(childPosTemp, newItem);
|
||||
childPosTemp++;
|
||||
} while (itemsCursor.moveToNext());
|
||||
itemsCursor.close();
|
||||
}
|
||||
return mItemsArrayList.get(groupPosition).get(childPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getChildId(int groupPosition, int childPosition) {
|
||||
return ((ConcreteFeedItem)(getChild(groupPosition, childPosition))).id_database;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getChildView(int groupPosition, int childPosition,
|
||||
boolean isLastChild, View convertView, ViewGroup parent) {
|
||||
LinearLayout view;
|
||||
|
||||
ConcreteFeedItem item = (ConcreteFeedItem)getChild(groupPosition, childPosition);
|
||||
|
||||
if (convertView == null) {
|
||||
view = new LinearLayout(mContext);
|
||||
String inflater = Context.LAYOUT_INFLATER_SERVICE;
|
||||
LayoutInflater vi = (LayoutInflater) mContext.getSystemService(inflater);
|
||||
vi.inflate(R.layout.subscription_list_sub_item, view, true);
|
||||
if(item != null)
|
||||
view.setTag(item.id_database);
|
||||
} else {
|
||||
view = (LinearLayout) convertView;
|
||||
}
|
||||
|
||||
if(item != null)
|
||||
{
|
||||
TextView textTV = (TextView) view.findViewById(R.id.summary);
|
||||
String headerText = (item.header != null) ? item.header : "";
|
||||
textTV.setText(headerText);
|
||||
|
||||
boolean execludeStarredItems = (item.folder_id.equals(ALL_STARRED_ITEMS)) ? false : true;
|
||||
|
||||
TextView tV_UnreadCount = (TextView) view.findViewById(R.id.tv_unreadCount);
|
||||
if(tV_UnreadCount.getTag() == null)//TODO Work on this here...
|
||||
tV_UnreadCount.setText("");
|
||||
SetUnreadCountForFeed(tV_UnreadCount, String.valueOf(item.id_database), execludeStarredItems);
|
||||
|
||||
ImageView imgView = (ImageView) view.findViewById(R.id.iVFavicon);
|
||||
GetFavIconForFeed(item.favIcon, imgView);
|
||||
}
|
||||
else
|
||||
{
|
||||
TextView textTV = (TextView) view.findViewById(R.id.summary);
|
||||
textTV.setText("Sorry, something went wrong here :(");
|
||||
|
||||
TextView tV_UnreadCount = (TextView) view.findViewById(R.id.tv_unreadCount);
|
||||
tV_UnreadCount.setText("0");
|
||||
|
||||
ImageView imgView = (ImageView) view.findViewById(R.id.iVFavicon);
|
||||
imgView.setImageDrawable(null);
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChildrenCount(int groupPosition) {
|
||||
int count;
|
||||
if(mItemsArrayList.indexOfKey(groupPosition) < 0){
|
||||
Cursor itemsCursor = dbConn.getAllSubscriptionForFolder(String.valueOf(getGroupId(groupPosition)), showOnlyUnread);
|
||||
count = itemsCursor.getCount();
|
||||
itemsCursor.close();
|
||||
}
|
||||
else
|
||||
count = mItemsArrayList.get(groupPosition).size();
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getGroup(int groupPosition) {
|
||||
return mCategoriesArrayList.get(groupPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupCount() {
|
||||
return mCategoriesArrayList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getGroupId(int groupPosition) {
|
||||
return ((AbstractItem)getGroup(groupPosition)).id_database;
|
||||
}
|
||||
|
||||
@SuppressLint("CutPasteId")
|
||||
@Override
|
||||
public View getGroupView(int groupPosition, boolean isExpanded,
|
||||
View convertView, ViewGroup parent) {
|
||||
LinearLayout view;
|
||||
//View view;
|
||||
GroupHolder viewHolder;
|
||||
|
||||
final FolderSubscribtionItem group = (FolderSubscribtionItem)getGroup(groupPosition);
|
||||
|
||||
if (convertView == null) {
|
||||
view = new LinearLayout(mContext);
|
||||
String inflater = Context.LAYOUT_INFLATER_SERVICE;
|
||||
LayoutInflater vi = (LayoutInflater) mContext.getSystemService(inflater);
|
||||
vi.inflate(R.layout.subscription_list_item, view, true);
|
||||
|
||||
ImageView indicatorImage = (ImageView) view.findViewById(R.id.img_View_expandable_indicator);
|
||||
TextView txt_Summary = (TextView) view.findViewById(R.id.summary);
|
||||
TextView textFeedCount = (TextView) view.findViewById(R.id.tV_feedsCount);
|
||||
|
||||
viewHolder = new GroupHolder();
|
||||
viewHolder.imgView = indicatorImage;
|
||||
viewHolder.txt_Summary = txt_Summary;
|
||||
viewHolder.txt_UnreadCount = textFeedCount;
|
||||
|
||||
viewHolder.txt_Summary.setClickable(true);
|
||||
|
||||
view.setTag(viewHolder);
|
||||
//view = convertView;
|
||||
convertView = view;
|
||||
|
||||
} else {
|
||||
view = (LinearLayout) convertView;
|
||||
viewHolder = (GroupHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
|
||||
viewHolder.txt_Summary.setText(group.headerFolder);
|
||||
viewHolder.txt_Summary.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//v.setPressed(true);
|
||||
//v.setSelected(true);
|
||||
//v.setBackgroundColor(mContext.getResources().getColor(android.R.color.holo_blue_light));
|
||||
//NewsReaderActivity.StartSubscriptionActivity((View) v.getParent().getParent(), mContext);
|
||||
//v.setBackgroundColor(mContext.getResources().getColor(android.R.color.transparent));
|
||||
//group.id;
|
||||
//ExpandableListView exListView = ((ExpandableListView) v.getParent().getParent().getParent());
|
||||
//exListView.setEmptyView(tView);
|
||||
//exListView.getSelectedPosition();
|
||||
|
||||
//String val = String.valueOf(((View) v.getParent().getParent()).getTag());
|
||||
String val = String.valueOf(group.id_database /*((LinearLayout) v.getParent()).getChildAt(1).getTag()*/);
|
||||
boolean skipFireEvent = false;
|
||||
if(group.idFolder != null)
|
||||
{
|
||||
if(group.idFolder.equals(ITEMS_WITHOUT_FOLDER))
|
||||
{
|
||||
fireListTextClicked(val, mContext, false, group.idFolder);
|
||||
skipFireEvent = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!skipFireEvent)
|
||||
fireListTextClicked(val, mContext, true, group.idFolder);
|
||||
}
|
||||
});
|
||||
/*
|
||||
if(viewHolder.txt_UnreadCount.getText() == "")
|
||||
{
|
||||
String unreadCountText = null;
|
||||
boolean skipGetUnread = false;
|
||||
if(group.idFolder != null)
|
||||
{
|
||||
if(group.idFolder.equals(ITEMS_WITHOUT_FOLDER))
|
||||
{
|
||||
unreadCountText = dbConn.getCountItemsForSubscription(String.valueOf(group.id_database), true, true) + "/" + dbConn.getCountItemsForSubscription(String.valueOf(group.id_database), false, true);
|
||||
skipGetUnread = true;
|
||||
}
|
||||
}
|
||||
if(!skipGetUnread)
|
||||
unreadCountText = dbConn.getCountFeedsForFolder(String.valueOf(group.id_database), true) + "/" + dbConn.getCountFeedsForFolder(String.valueOf(group.id_database), false);
|
||||
|
||||
viewHolder.txt_UnreadCount.setText(unreadCountText);
|
||||
}*/
|
||||
|
||||
boolean skipGetUnread = false;
|
||||
if(group.idFolder != null)
|
||||
{
|
||||
if(group.idFolder.equals(ITEMS_WITHOUT_FOLDER))
|
||||
{
|
||||
//unreadCountText = getUnreadTextItems(String.valueOf(group.id_database), true, true);
|
||||
SetUnreadCountForFeed(viewHolder.txt_UnreadCount, String.valueOf(group.id_database), true);
|
||||
skipGetUnread = true;
|
||||
}
|
||||
}
|
||||
if(!skipGetUnread)
|
||||
SetUnreadCountForFolder(viewHolder.txt_UnreadCount, String.valueOf(group.id_database), true);
|
||||
//unreadCountText = getUnreadTextFolder(String.valueOf(group.id_database), true);
|
||||
|
||||
|
||||
viewHolder.txt_UnreadCount.setText("");
|
||||
|
||||
|
||||
//viewHolder.txt_UnreadCount.setText(group.unreadCount);
|
||||
|
||||
if(group.idFolder != null)
|
||||
{
|
||||
if(group.idFolder.equals(ITEMS_WITHOUT_FOLDER))
|
||||
{
|
||||
Cursor cursor = dbConn.getFeedByDbID(String.valueOf(group.id_database));
|
||||
if(cursor != null)
|
||||
{
|
||||
if(cursor.getCount() > 0)
|
||||
{
|
||||
cursor.moveToFirst();
|
||||
String favIconURL = cursor.getString(cursor.getColumnIndex(DatabaseConnection.SUBSCRIPTION_FAVICON_URL));
|
||||
GetFavIconForFeed(favIconURL, viewHolder.imgView);
|
||||
}
|
||||
}
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(String.valueOf(group.id_database).equals(ALL_STARRED_ITEMS))
|
||||
{
|
||||
viewHolder.imgView.setVisibility( View.VISIBLE );
|
||||
viewHolder.imgView.setImageResource(R.drawable.star);
|
||||
} else if (getChildrenCount( groupPosition ) == 0 ) {
|
||||
viewHolder.imgView.setVisibility( View.INVISIBLE );
|
||||
//viewHolder.imgView.setImageDrawable(null);
|
||||
}
|
||||
else {
|
||||
viewHolder.imgView.setVisibility( View.VISIBLE );
|
||||
if(ThemeChooser.isDarkTheme(mContext))
|
||||
viewHolder.imgView.setImageResource( isExpanded ? R.drawable.ic_find_previous_holo_dark : R.drawable.ic_find_next_holo_dark);
|
||||
else
|
||||
viewHolder.imgView.setImageResource( isExpanded ? R.drawable.ic_find_previous_holo_light : R.drawable.ic_find_next_holo_light);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//view.setTag(group.id_database);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
private void SetUnreadCountForFeed(TextView textView, String idDatabase, boolean execludeStarredItems)
|
||||
{
|
||||
IGetTextForTextViewAsyncTask iGetter = new UnreadFeedCount(mContext, idDatabase, execludeStarredItems);
|
||||
new FillTextForTextViewAsyncTask(textView, iGetter).execute((Void) null);
|
||||
}
|
||||
|
||||
private void SetUnreadCountForFolder(TextView textView, String idDatabase, boolean execludeStarredItems)
|
||||
{
|
||||
IGetTextForTextViewAsyncTask iGetter = new UnreadFolderCount(mContext, idDatabase);
|
||||
new FillTextForTextViewAsyncTask(textView, iGetter).execute((Void) null);
|
||||
}
|
||||
|
||||
private void GetFavIconForFeed(String favIconURL, ImageView imgView)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(favIconURL != null)
|
||||
{
|
||||
|
||||
if(favIconURL.trim().length() > 0)
|
||||
{
|
||||
FavIconHandler.GetImageAsync(imgView, favIconURL, mContext);
|
||||
//new FavIconHandler.GetImageFromWebAsyncTask(favIconURL, mContext, imgView).execute((Void)null);
|
||||
}
|
||||
else
|
||||
imgView.setImageResource(FavIconHandler.getResourceIdForRightDefaultFeedIcon(mContext));
|
||||
}
|
||||
else
|
||||
imgView.setImageResource(FavIconHandler.getResourceIdForRightDefaultFeedIcon(mContext));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
static class GroupHolder
|
||||
{
|
||||
TextView txt_Summary;
|
||||
TextView txt_UnreadCount;
|
||||
ImageView imgView;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasStableIds() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChildSelectable(int groupPosition, int childPosition) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public void registerDataSetObserver(DataSetObserver observer) {
|
||||
//used to make the notifyDataSetChanged() method work
|
||||
super.registerDataSetObserver(observer);
|
||||
}*/
|
||||
|
||||
public void ReloadAdapter()
|
||||
{
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(mContext);
|
||||
showOnlyUnread = mPrefs.getBoolean(SettingsActivity.CB_SHOWONLYUNREAD_STRING, false);
|
||||
|
||||
mCategoriesArrayList = new ArrayList<FolderSubscribtionItem>();
|
||||
mCategoriesArrayList.add(new FolderSubscribtionItem(mContext.getString(R.string.allUnreadFeeds), null, Long.valueOf(ALL_UNREAD_ITEMS)));
|
||||
mCategoriesArrayList.add(new FolderSubscribtionItem(mContext.getString(R.string.starredFeeds), null, Long.valueOf(ALL_STARRED_ITEMS)));
|
||||
|
||||
//mCategoriesArrayList.add(new FolderSubscribtionItem(mContext.getString(R.string.starredFeeds), -11, null, null));
|
||||
|
||||
AddEverythingInCursorFolderToSubscriptions(dbConn.getAllTopSubscriptions(showOnlyUnread));
|
||||
AddEverythingInCursorFeedsToSubscriptions(dbConn.getAllTopSubscriptionsWithoutFolder(showOnlyUnread));
|
||||
|
||||
//AddEverythingInCursorToSubscriptions(dbConn.getAllTopSubscriptionsWithUnreadFeeds());
|
||||
mItemsArrayList = new SparseArray<SparseArray<ConcreteFeedItem>>();
|
||||
|
||||
this.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
||||
public void setHandlerListener(ExpListTextClicked listener)
|
||||
{
|
||||
eListTextClickHandler = listener;
|
||||
}
|
||||
protected void fireListTextClicked(String idSubscription, Context context, boolean isFolder, String optional_folder_id)
|
||||
{
|
||||
if(eListTextClickHandler != null)
|
||||
eListTextClickHandler.onTextClicked(idSubscription, context, isFolder, optional_folder_id);
|
||||
}
|
||||
}
|
|
@ -23,6 +23,7 @@ import com.actionbarsherlock.view.Menu;
|
|||
import com.actionbarsherlock.view.MenuItem;
|
||||
|
||||
import de.luhmer.owncloudnewsreader.database.DatabaseConnection;
|
||||
import de.luhmer.owncloudnewsreader.helper.PostDelayHandler;
|
||||
import de.luhmer.owncloudnewsreader.helper.ThemeChooser;
|
||||
import de.luhmer.owncloudnewsreader.reader.IReader;
|
||||
import de.luhmer.owncloudnewsreader.reader.owncloud.OwnCloud_Reader;
|
||||
|
@ -45,6 +46,8 @@ public class NewsDetailActivity extends SherlockFragmentActivity {
|
|||
public ViewPager mViewPager;
|
||||
private int currentPosition;
|
||||
|
||||
PostDelayHandler pDelayHandler;
|
||||
|
||||
MenuItem menuItem_Starred;
|
||||
MenuItem menuItem_Read;
|
||||
|
||||
|
@ -63,6 +66,8 @@ public class NewsDetailActivity extends SherlockFragmentActivity {
|
|||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_news_detail);
|
||||
|
||||
pDelayHandler = new PostDelayHandler(this);
|
||||
|
||||
_Reader = new OwnCloud_Reader();
|
||||
dbConn = new DatabaseConnection(this);
|
||||
Intent intent = getIntent();
|
||||
|
@ -209,6 +214,8 @@ public class NewsDetailActivity extends SherlockFragmentActivity {
|
|||
{
|
||||
markItemAsReadUnread(idFeed, true);
|
||||
|
||||
pDelayHandler.DelayTimer();
|
||||
|
||||
//Cursor cur = dbConn.getArticleByID(idFeed);
|
||||
//cur.moveToFirst();
|
||||
//GoogleReaderMethods.MarkItemAsRead(true, cur, dbConn, getApplicationContext(), asyncTaskCompletedPerformTagRead);
|
||||
|
@ -300,6 +307,8 @@ public class NewsDetailActivity extends SherlockFragmentActivity {
|
|||
dbConn.updateIsStarredOfFeed(idItem_Db, !curState);
|
||||
|
||||
UpdateActionBarIcons();
|
||||
|
||||
pDelayHandler.DelayTimer();
|
||||
|
||||
List<String> idItems = new ArrayList<String>();
|
||||
cursor.moveToFirst();
|
||||
|
@ -394,6 +403,8 @@ public class NewsDetailActivity extends SherlockFragmentActivity {
|
|||
cursor.close();
|
||||
}
|
||||
|
||||
pDelayHandler.DelayTimer();
|
||||
|
||||
break;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
|
|
|
@ -34,6 +34,7 @@ import de.luhmer.owncloudnewsreader.reader.FeedItemTags.TAGS;
|
|||
import de.luhmer.owncloudnewsreader.reader.IReader;
|
||||
import de.luhmer.owncloudnewsreader.reader.OnAsyncTaskCompletedListener;
|
||||
import de.luhmer.owncloudnewsreader.reader.owncloud.API;
|
||||
import de.luhmer.owncloudnewsreader.reader.owncloud.OwnCloudConstants;
|
||||
import de.luhmer.owncloudnewsreader.reader.owncloud.OwnCloud_Reader;
|
||||
import de.luhmer.owncloudnewsreader.reader.owncloud.apiv1.APIv1;
|
||||
import de.luhmer.owncloudnewsreader.reader.owncloud.apiv2.APIv2;
|
||||
|
@ -163,7 +164,7 @@ public class NewsReaderListFragment extends SherlockFragment implements OnCreate
|
|||
if (!_Reader.isSyncRunning())
|
||||
{
|
||||
OwnCloud_Reader ocReader = (OwnCloud_Reader) _Reader;
|
||||
ocReader.Start_AsyncTask_GetVersion(-10, getActivity(), onAsyncTask_GetVersionFinished, username, password);
|
||||
ocReader.Start_AsyncTask_GetVersion(Constants.TaskID_GetVersion, getActivity(), onAsyncTask_GetVersionFinished, username, password);
|
||||
}
|
||||
else
|
||||
_Reader.attachToRunningTask(-10, getActivity(), onAsyncTask_GetVersionFinished);
|
||||
|
@ -193,32 +194,12 @@ public class NewsReaderListFragment extends SherlockFragment implements OnCreate
|
|||
api = new APIv1(getActivity());
|
||||
}
|
||||
|
||||
((OwnCloud_Reader) _Reader).setApi(api);
|
||||
((OwnCloud_Reader) _Reader).setApi(api);
|
||||
|
||||
DatabaseConnection dbConn = new DatabaseConnection(getActivity());
|
||||
try {
|
||||
//Mark as READ
|
||||
List<String> item_ids = dbConn.getAllNewReadItems();
|
||||
_Reader.Start_AsyncTask_PerformTagAction(-4, getActivity(), onAsyncTask_PerformTagExecute, item_ids, TAGS.MARK_ITEM_AS_READ);
|
||||
|
||||
//Mark as UNREAD
|
||||
item_ids = dbConn.getAllNewUnreadItems();
|
||||
_Reader.Start_AsyncTask_PerformTagAction(-3, getActivity(), onAsyncTask_PerformTagExecute, item_ids, TAGS.MARK_ITEM_AS_UNREAD);
|
||||
|
||||
//Mark as STARRED
|
||||
item_ids = dbConn.getAllNewStarredItems();
|
||||
_Reader.Start_AsyncTask_PerformTagAction(-2, getActivity(), onAsyncTask_PerformTagExecute, item_ids, TAGS.MARK_ITEM_AS_STARRED);
|
||||
|
||||
//Mark as UNSTARRED
|
||||
item_ids = dbConn.getAllNewUnstarredItems();
|
||||
_Reader.Start_AsyncTask_PerformTagAction(-1, getActivity(), onAsyncTask_PerformTagExecute, item_ids, TAGS.MARK_ITEM_AS_UNSTARRED);
|
||||
} finally {
|
||||
dbConn.closeDatabase();
|
||||
}
|
||||
|
||||
_Reader.Start_AsyncTask_PerformItemStateChange(Constants.TaskID_PerformStateChange, getActivity(), onAsyncTask_PerformTagExecute);
|
||||
|
||||
if(eListView != null)
|
||||
eListView.getLoadingLayoutProxy().setLastUpdatedLabel(getString(R.string.pull_to_refresh_updateTags));
|
||||
//_Reader.Start_AsyncTask_GetFolder(0, getActivity(), onAsyncTask_GetTopReaderTags);
|
||||
}
|
||||
UpdateSyncButtonLayout();
|
||||
}
|
||||
|
@ -234,9 +215,9 @@ public class NewsReaderListFragment extends SherlockFragment implements OnCreate
|
|||
{
|
||||
//dbConn.resetDatabase();
|
||||
|
||||
if(task_id == -1)
|
||||
if(task_id == Constants.TaskID_PerformStateChange)
|
||||
{
|
||||
_Reader.Start_AsyncTask_GetFolder(1, getActivity(), onAsyncTask_GetFolder);
|
||||
_Reader.Start_AsyncTask_GetFolder(Constants.TaskID_GetFolder, getActivity(), onAsyncTask_GetFolder);
|
||||
if(eListView != null)
|
||||
eListView.getLoadingLayoutProxy().setLastUpdatedLabel(getString(R.string.pull_to_refresh_updateFolder));
|
||||
}
|
||||
|
@ -257,8 +238,7 @@ public class NewsReaderListFragment extends SherlockFragment implements OnCreate
|
|||
|
||||
@Override
|
||||
public void onAsyncTaskCompleted(int task_id, Object task_result) {
|
||||
Log.d(TAG, "onAsyncTask_GetTopReaderTags started: " + task_id);
|
||||
|
||||
|
||||
if(task_result != null)
|
||||
{
|
||||
if(task_result instanceof HttpHostConnectException)
|
||||
|
@ -278,13 +258,14 @@ public class NewsReaderListFragment extends SherlockFragment implements OnCreate
|
|||
}
|
||||
else
|
||||
{
|
||||
_Reader.Start_AsyncTask_GetFeeds(1, getActivity(), onAsyncTask_GetFeed);
|
||||
_Reader.Start_AsyncTask_GetFeeds(Constants.TaskID_GetFeeds, getActivity(), onAsyncTask_GetFeed);
|
||||
if(eListView != null)
|
||||
eListView.getLoadingLayoutProxy().setLastUpdatedLabel(getString(R.string.pull_to_refresh_updateFeeds));
|
||||
}
|
||||
|
||||
lvAdapter.notifyDataSetChanged();
|
||||
Log.d(TAG, "onAsyncTask_GetTopReaderTags Finished");
|
||||
|
||||
Log.d(TAG, "onAsyncTask_GetFolder Finished");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -297,9 +278,6 @@ public class NewsReaderListFragment extends SherlockFragment implements OnCreate
|
|||
|
||||
@Override
|
||||
public void onAsyncTaskCompleted(int task_id, Object task_result) {
|
||||
|
||||
Log.d(TAG, "onAsyncTask_GetSubReaderTags Finished");
|
||||
|
||||
if(task_result != null)
|
||||
{
|
||||
ShowToastLong(((Exception)task_result).getLocalizedMessage());
|
||||
|
@ -309,7 +287,7 @@ public class NewsReaderListFragment extends SherlockFragment implements OnCreate
|
|||
{
|
||||
//dbConn.resetRssItemsDatabase();
|
||||
|
||||
_Reader.Start_AsyncTask_GetItems(2, getActivity(), onAsyncTask_GetItems, TAGS.ALL);//Recieve all unread Items
|
||||
_Reader.Start_AsyncTask_GetItems(Constants.TaskID_GetItems, getActivity(), onAsyncTask_GetItems, TAGS.ALL);//Recieve all unread Items
|
||||
//_Reader.Start_AsyncTask_GetFeeds(3, getActivity(), onAsyncTask_GetFeeds, TAGS.ALL_STARRED);//Recieve all starred Items
|
||||
|
||||
if(eListView != null)
|
||||
|
@ -319,6 +297,8 @@ public class NewsReaderListFragment extends SherlockFragment implements OnCreate
|
|||
|
||||
|
||||
lvAdapter.ReloadAdapter();
|
||||
|
||||
Log.d(TAG, "onAsyncTask_GetFeed Finished");
|
||||
//lvAdapter.notifyDataSetChanged();
|
||||
//eListView.setAdapter(new SubscriptionExpandableListAdapter(getActivity(), dbConn));
|
||||
|
||||
|
@ -336,10 +316,6 @@ public class NewsReaderListFragment extends SherlockFragment implements OnCreate
|
|||
ShowToastLong(((Exception)task_result).getLocalizedMessage());
|
||||
|
||||
lvAdapter.notifyDataSetChanged();
|
||||
//Activity act = getActivity();
|
||||
//lvAdapter = new SubscriptionExpandableListAdapter(act, dbConn);
|
||||
|
||||
Log.d(TAG, "onAsyncTask_GetFeeds Finished");
|
||||
|
||||
if(eListView != null)
|
||||
eListView.getLoadingLayoutProxy().setLastUpdatedLabel(null);
|
||||
|
@ -351,6 +327,8 @@ public class NewsReaderListFragment extends SherlockFragment implements OnCreate
|
|||
NewsReaderListActivity nlActivity = (NewsReaderListActivity) getActivity();
|
||||
nlActivity.UpdateItemList();
|
||||
|
||||
|
||||
Log.d(TAG, "onAsyncTask_GetItems Finished");
|
||||
//fireUpdateFinishedClicked();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -32,6 +32,7 @@ import de.luhmer.owncloudnewsreader.NewsReaderListActivity;
|
|||
import de.luhmer.owncloudnewsreader.R;
|
||||
import de.luhmer.owncloudnewsreader.SettingsActivity;
|
||||
import de.luhmer.owncloudnewsreader.database.DatabaseConnection;
|
||||
import de.luhmer.owncloudnewsreader.helper.PostDelayHandler;
|
||||
import de.luhmer.owncloudnewsreader.reader.IReader;
|
||||
import de.luhmer.owncloudnewsreader.reader.owncloud.OwnCloud_Reader;
|
||||
|
||||
|
@ -42,6 +43,8 @@ public class NewsListCursorAdapter extends CursorAdapter {
|
|||
final int LengthBody = 300;
|
||||
ForegroundColorSpan bodyForegroundColor;
|
||||
|
||||
PostDelayHandler pDelayHandler;
|
||||
|
||||
int selectedDesign = 0;
|
||||
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
|
@ -49,6 +52,8 @@ public class NewsListCursorAdapter extends CursorAdapter {
|
|||
public NewsListCursorAdapter(Context context, Cursor c) {
|
||||
super(context, c);
|
||||
|
||||
pDelayHandler = new PostDelayHandler(context);
|
||||
|
||||
simpleDateFormat = new SimpleDateFormat("EEE, d. MMM HH:mm:ss");
|
||||
bodyForegroundColor = new ForegroundColorSpan(context.getResources().getColor(android.R.color.secondary_text_dark));
|
||||
|
||||
|
@ -110,6 +115,8 @@ public class NewsListCursorAdapter extends CursorAdapter {
|
|||
if(isChecked)
|
||||
UpdateIsReadCheckBox(buttonView, idItemDb);
|
||||
|
||||
pDelayHandler.DelayTimer();
|
||||
|
||||
/*
|
||||
List<String> idItems = new ArrayList<String>();
|
||||
idItems.add(idItem);
|
||||
|
@ -137,6 +144,9 @@ public class NewsListCursorAdapter extends CursorAdapter {
|
|||
|
||||
dbConn.updateIsReadOfFeed(idItemDb, isChecked);
|
||||
UpdateListCursor(mContext);
|
||||
|
||||
pDelayHandler.DelayTimer();
|
||||
|
||||
/*
|
||||
//TODO THIS IS IMPORTANT CODE !
|
||||
List<String> idItems = new ArrayList<String>();
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
package de.luhmer.owncloudnewsreader.reader;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
public abstract class AsyncTask_Reader extends AsyncTask<Object, Void, Object> {
|
||||
protected Activity context;
|
||||
protected Context context;
|
||||
protected int task_id;
|
||||
protected OnAsyncTaskCompletedListener[] listener;
|
||||
|
||||
public AsyncTask_Reader(final int task_id, final Activity context, final OnAsyncTaskCompletedListener[] listener) {
|
||||
public AsyncTask_Reader(final int task_id, final Context context, final OnAsyncTaskCompletedListener[] listener) {
|
||||
this.context = context;
|
||||
this.task_id = task_id;
|
||||
this.listener = listener;
|
||||
|
|
|
@ -41,6 +41,16 @@ public class HttpJsonRequest {
|
|||
|
||||
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
|
||||
|
||||
// Define an array of pins. One of these must be present
|
||||
// in the certificate chain you receive. A pin is a hex-encoded
|
||||
// hash of a X.509 certificate's SubjectPublicKeyInfo. A pin can
|
||||
// be generated using the provided pin.py script:
|
||||
// python ./tools/pin.py certificate_file.pem
|
||||
|
||||
//String[] pins = new String[] {"f30012bbc18c231ac1a44b788e410ce754182513"};
|
||||
//HttpsURLConnection connection = PinningHelper.getPinnedHttpsURLConnection(context, pins, url);
|
||||
|
||||
|
||||
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
/*
|
||||
|
@ -54,12 +64,7 @@ public class HttpJsonRequest {
|
|||
|
||||
if(username != null && password != null)
|
||||
urlConnection.setRequestProperty("Authorization", "Basic " + Base64.encode((username + ":" + password).getBytes()));
|
||||
/*
|
||||
Authenticator.setDefault(new Authenticator(){
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
return new PasswordAuthentication(username, password.toCharArray());
|
||||
}});*/
|
||||
|
||||
|
||||
urlConnection.setDoOutput(false);
|
||||
urlConnection.setDoInput(true);
|
||||
urlConnection.setRequestMethod("GET");
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package de.luhmer.owncloudnewsreader.reader;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.util.SparseArray;
|
||||
|
||||
public interface IReader {
|
||||
|
@ -17,7 +16,7 @@ public interface IReader {
|
|||
|
||||
public void Start_AsyncTask_GetFolder(final int task_id, final Activity context, final OnAsyncTaskCompletedListener listener);
|
||||
public void Start_AsyncTask_GetFeeds(final int task_id, final Activity context, final OnAsyncTaskCompletedListener listener);
|
||||
public void Start_AsyncTask_PerformTagAction(final int task_id, final Activity context, final OnAsyncTaskCompletedListener listener, List<String> itemIds, FeedItemTags.TAGS tag);
|
||||
public void Start_AsyncTask_PerformItemStateChange(final int task_id, final Context context, final OnAsyncTaskCompletedListener listener);
|
||||
public void Start_AsyncTask_Authenticate(final int task_id, final Activity context, final OnAsyncTaskCompletedListener listener);
|
||||
|
||||
public abstract void onAsyncTaskCompleted(final int task_id, final Object task_result);
|
||||
|
|
|
@ -2,7 +2,6 @@ package de.luhmer.owncloudnewsreader.reader.owncloud;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
|
@ -13,8 +12,8 @@ import de.luhmer.owncloudnewsreader.reader.FeedItemTags.TAGS;
|
|||
public abstract class API {
|
||||
protected SharedPreferences mPrefs;
|
||||
|
||||
public API(Activity act) {
|
||||
mPrefs = PreferenceManager.getDefaultSharedPreferences(act);
|
||||
public API(Context cont) {
|
||||
mPrefs = PreferenceManager.getDefaultSharedPreferences(cont);
|
||||
}
|
||||
|
||||
protected abstract String getItemUrl();
|
||||
|
@ -24,8 +23,6 @@ public abstract class API {
|
|||
|
||||
protected abstract String getTagBaseUrl();
|
||||
|
||||
//public abstract void markSingleItemAsReadApiv1();
|
||||
|
||||
public String getUsername() {
|
||||
return mPrefs.getString(SettingsActivity.EDT_USERNAME_STRING, null);
|
||||
}
|
||||
|
@ -34,25 +31,21 @@ public abstract class API {
|
|||
return mPrefs.getString(SettingsActivity.EDT_PASSWORD_STRING, null);
|
||||
}
|
||||
|
||||
public int GetFeeds(Activity act, API api) throws Exception {
|
||||
return OwnCloudReaderMethods.GetFeeds(act, api);
|
||||
public int GetFeeds(Context cont, API api) throws Exception {
|
||||
return OwnCloudReaderMethods.GetFeeds(cont, api);
|
||||
}
|
||||
|
||||
public int GetFolderTags(Activity act, API api) throws Exception {
|
||||
return OwnCloudReaderMethods.GetFolderTags(act, api);
|
||||
public int GetFolderTags(Context cont, API api) throws Exception {
|
||||
return OwnCloudReaderMethods.GetFolderTags(cont, api);
|
||||
}
|
||||
|
||||
public int GetItems(TAGS tag, Activity act, String offset, boolean getRead, String id, String type, API api) throws Exception {
|
||||
return OwnCloudReaderMethods.GetItems(tag, act, offset, getRead, id, type, api);
|
||||
public int GetItems(TAGS tag, Context cont, String offset, boolean getRead, String id, String type, API api) throws Exception {
|
||||
return OwnCloudReaderMethods.GetItems(tag, cont, offset, getRead, id, type, api);
|
||||
}
|
||||
|
||||
public int GetUpdatedItems(TAGS tag, Activity act, long lastSync, API api) throws Exception {
|
||||
return OwnCloudReaderMethods.GetUpdatedItems(tag, act, lastSync, api);
|
||||
public int GetUpdatedItems(TAGS tag, Context cont, long lastSync, API api) throws Exception {
|
||||
return OwnCloudReaderMethods.GetUpdatedItems(tag, cont, lastSync, api);
|
||||
}
|
||||
|
||||
public abstract boolean PerformTagExecution(List<String> itemIds, FeedItemTags.TAGS tag, Context context, API api);
|
||||
/*
|
||||
public boolean PerformTagExecution(List<String> itemIds, FeedItemTags.TAGS tag, Context context, API api) {
|
||||
return OwnCloudReaderMethods.PerformTagExecution(itemIds, tag, context, api);
|
||||
}*/
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package de.luhmer.owncloudnewsreader.reader.owncloud;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import de.luhmer.owncloudnewsreader.SettingsActivity;
|
||||
|
@ -12,7 +12,7 @@ public class AsyncTask_GetApiVersion extends AsyncTask_Reader {
|
|||
private String username;
|
||||
private String password;
|
||||
|
||||
public AsyncTask_GetApiVersion(final int task_id, final Activity context, String username, String password, final OnAsyncTaskCompletedListener[] listener) {
|
||||
public AsyncTask_GetApiVersion(final int task_id, final Context context, String username, String password, final OnAsyncTaskCompletedListener[] listener) {
|
||||
super(task_id, context, listener);
|
||||
|
||||
this.username = username;
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
package de.luhmer.owncloudnewsreader.reader.owncloud;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import de.luhmer.owncloudnewsreader.reader.AsyncTask_Reader;
|
||||
import de.luhmer.owncloudnewsreader.reader.OnAsyncTaskCompletedListener;
|
||||
import de.luhmer.owncloudnewsreader.reader.owncloud.apiv2.APIv2;
|
||||
|
||||
public class AsyncTask_GetFeeds extends AsyncTask_Reader {
|
||||
|
||||
public AsyncTask_GetFeeds(final int task_id, final Activity context, final OnAsyncTaskCompletedListener[] listener) {
|
||||
private API api;
|
||||
|
||||
public AsyncTask_GetFeeds(final int task_id, final Context context, final OnAsyncTaskCompletedListener[] listener, API api) {
|
||||
super(task_id, context, listener);
|
||||
this.api = api;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Exception doInBackground(Object... params) {
|
||||
API api = new APIv2(context);
|
||||
|
||||
try {
|
||||
api.GetFeeds(context, api);
|
||||
//OwnCloudReaderMethods.GetFeeds(context, api);
|
||||
} catch (Exception ex) {
|
||||
return ex;
|
||||
}
|
||||
|
|
|
@ -3,17 +3,18 @@ package de.luhmer.owncloudnewsreader.reader.owncloud;
|
|||
import android.app.Activity;
|
||||
import de.luhmer.owncloudnewsreader.reader.AsyncTask_Reader;
|
||||
import de.luhmer.owncloudnewsreader.reader.OnAsyncTaskCompletedListener;
|
||||
import de.luhmer.owncloudnewsreader.reader.owncloud.apiv2.APIv2;
|
||||
|
||||
public class AsyncTask_GetFolderTags extends AsyncTask_Reader {
|
||||
|
||||
public AsyncTask_GetFolderTags(final int task_id, final Activity context, final OnAsyncTaskCompletedListener[] listener) {
|
||||
private API api;
|
||||
|
||||
public AsyncTask_GetFolderTags(final int task_id, final Activity context, final OnAsyncTaskCompletedListener[] listener, API api) {
|
||||
super(task_id, context, listener);
|
||||
this.api = api;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Exception doInBackground(Object... params) {
|
||||
API api = new APIv2(context);
|
||||
|
||||
try {
|
||||
//OwnCloudReaderMethods.GetFolderTags(context, api);
|
||||
|
|
|
@ -14,14 +14,15 @@ import de.luhmer.owncloudnewsreader.helper.NetworkConnection;
|
|||
import de.luhmer.owncloudnewsreader.reader.AsyncTask_Reader;
|
||||
import de.luhmer.owncloudnewsreader.reader.FeedItemTags.TAGS;
|
||||
import de.luhmer.owncloudnewsreader.reader.OnAsyncTaskCompletedListener;
|
||||
import de.luhmer.owncloudnewsreader.reader.owncloud.apiv2.APIv2;
|
||||
import de.luhmer.owncloudnewsreader.services.DownloadImagesService;
|
||||
|
||||
public class AsyncTask_GetItems extends AsyncTask_Reader {
|
||||
private long highestItemIdBeforeSync;
|
||||
private long highestItemIdBeforeSync;
|
||||
private API api;
|
||||
|
||||
public AsyncTask_GetItems(final int task_id, final Activity context, final OnAsyncTaskCompletedListener[] listener) {
|
||||
public AsyncTask_GetItems(final int task_id, final Activity context, final OnAsyncTaskCompletedListener[] listener, API api) {
|
||||
super(task_id, context, listener);
|
||||
this.api = api;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -42,9 +43,7 @@ public class AsyncTask_GetItems extends AsyncTask_Reader {
|
|||
int maxItemsInDatabase = Constants.maxItemsCount;
|
||||
|
||||
highestItemIdBeforeSync = dbConn.getHighestItemId();
|
||||
|
||||
API api = new APIv2(context);
|
||||
|
||||
|
||||
if(lastModified == 0)
|
||||
{
|
||||
do {
|
||||
|
|
|
@ -8,19 +8,20 @@ import de.luhmer.owncloudnewsreader.database.DatabaseConnection;
|
|||
import de.luhmer.owncloudnewsreader.reader.AsyncTask_Reader;
|
||||
import de.luhmer.owncloudnewsreader.reader.FeedItemTags.TAGS;
|
||||
import de.luhmer.owncloudnewsreader.reader.OnAsyncTaskCompletedListener;
|
||||
import de.luhmer.owncloudnewsreader.reader.owncloud.apiv2.APIv2;
|
||||
|
||||
public class AsyncTask_GetOldItems extends AsyncTask_Reader {
|
||||
|
||||
public String feed_id;
|
||||
public String folder_id;
|
||||
private int downloadedItemsCount = 0;
|
||||
private API api;
|
||||
|
||||
public AsyncTask_GetOldItems(final int task_id, final Activity context, final OnAsyncTaskCompletedListener[] listener, String feed_id, String folder_id) {
|
||||
public AsyncTask_GetOldItems(final int task_id, final Activity context, final OnAsyncTaskCompletedListener[] listener, String feed_id, String folder_id, API api) {
|
||||
super(task_id, context, listener);
|
||||
|
||||
this.feed_id = feed_id;
|
||||
this.folder_id = folder_id;
|
||||
this.api = api;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -53,7 +54,6 @@ public class AsyncTask_GetOldItems extends AsyncTask_Reader {
|
|||
}
|
||||
}
|
||||
|
||||
API api = new APIv2(context);
|
||||
downloadedItemsCount = api.GetItems(TAGS.ALL, context, String.valueOf(offset), true, id, type, api);
|
||||
//downloadedItemsCount = OwnCloudReaderMethods.GetItems(TAGS.ALL, context, String.valueOf(offset), true, id, type, api);
|
||||
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
package de.luhmer.owncloudnewsreader.reader.owncloud;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import android.content.Context;
|
||||
import de.luhmer.owncloudnewsreader.database.DatabaseConnection;
|
||||
import de.luhmer.owncloudnewsreader.reader.AsyncTask_Reader;
|
||||
import de.luhmer.owncloudnewsreader.reader.FeedItemTags.TAGS;
|
||||
import de.luhmer.owncloudnewsreader.reader.OnAsyncTaskCompletedListener;
|
||||
|
||||
public class AsyncTask_PerformItemStateChange extends AsyncTask_Reader
|
||||
{
|
||||
private API api;
|
||||
|
||||
public AsyncTask_PerformItemStateChange(final int task_id, final Context context, final OnAsyncTaskCompletedListener[] listener, API api) {
|
||||
super(task_id, context, listener);
|
||||
this.api = api;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(Object... params) {
|
||||
|
||||
List<Boolean> succeeded = new ArrayList<Boolean>();
|
||||
|
||||
try {
|
||||
DatabaseConnection dbConn = new DatabaseConnection(context);
|
||||
try {
|
||||
//Mark as READ
|
||||
List<String> itemIds = dbConn.getAllNewReadItems();
|
||||
succeeded.add(api.PerformTagExecution(itemIds, TAGS.MARK_ITEM_AS_READ, context, api));
|
||||
|
||||
//Mark as UNREAD
|
||||
itemIds = dbConn.getAllNewUnreadItems();
|
||||
succeeded.add(api.PerformTagExecution(itemIds, TAGS.MARK_ITEM_AS_UNREAD, context, api));
|
||||
|
||||
//Mark as STARRED
|
||||
itemIds = dbConn.getAllNewStarredItems();
|
||||
succeeded.add(api.PerformTagExecution(itemIds, TAGS.MARK_ITEM_AS_STARRED, context, api));
|
||||
|
||||
//Mark as UNSTARRED
|
||||
itemIds = dbConn.getAllNewUnstarredItems();
|
||||
succeeded.add(api.PerformTagExecution(itemIds, TAGS.MARK_ITEM_AS_UNSTARRED, context, api));
|
||||
} finally {
|
||||
dbConn.closeDatabase();
|
||||
}
|
||||
//if(itemIds.size() > 0)
|
||||
// return api.PerformTagExecution(itemIds, tag, context, api);
|
||||
//else
|
||||
// return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
succeeded.add(false);
|
||||
}
|
||||
|
||||
if(succeeded.contains(false))
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Object values) {
|
||||
for (OnAsyncTaskCompletedListener listenerInstance : listener) {
|
||||
if(listenerInstance != null)
|
||||
listenerInstance.onAsyncTaskCompleted(task_id, values);
|
||||
}
|
||||
|
||||
detach();
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
package de.luhmer.owncloudnewsreader.reader.owncloud;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.AsyncTask;
|
||||
import de.luhmer.owncloudnewsreader.reader.AsyncTask_Reader;
|
||||
import de.luhmer.owncloudnewsreader.reader.FeedItemTags.TAGS;
|
||||
import de.luhmer.owncloudnewsreader.reader.OnAsyncTaskCompletedListener;
|
||||
import de.luhmer.owncloudnewsreader.reader.owncloud.apiv2.APIv2;
|
||||
|
||||
public class AsyncTask_PerformTagAction extends AsyncTask_Reader {
|
||||
|
||||
public AsyncTask_PerformTagAction(final int task_id, final Activity context, final OnAsyncTaskCompletedListener[] listener) {
|
||||
super(task_id, context, listener);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected Boolean doInBackground(Object... params) {
|
||||
List<String> itemIds = (List<String>) params[0];
|
||||
TAGS tag = (TAGS) params[1];
|
||||
|
||||
try {
|
||||
//String authKey = AuthenticationManager.getGoogleAuthKey(username, password);
|
||||
API api = new APIv2(context);
|
||||
|
||||
if(itemIds.size() > 0)
|
||||
return api.PerformTagExecution(itemIds, tag, context, api);
|
||||
else
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Object values) {
|
||||
for (OnAsyncTaskCompletedListener listenerInstance : listener) {
|
||||
if(listenerInstance != null)
|
||||
listenerInstance.onAsyncTaskCompleted(task_id, values);
|
||||
}
|
||||
|
||||
detach();
|
||||
}
|
||||
}
|
|
@ -14,7 +14,6 @@ import org.json.JSONArray;
|
|||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
|
||||
|
@ -28,7 +27,7 @@ import de.luhmer.owncloudnewsreader.reader.HttpJsonRequest;
|
|||
public class OwnCloudReaderMethods {
|
||||
public static String maxSizePerSync = "200";
|
||||
|
||||
public static int GetUpdatedItems(TAGS tag, Activity act, long lastSync, API api) throws Exception
|
||||
public static int GetUpdatedItems(TAGS tag, Context cont, long lastSync, API api) throws Exception
|
||||
{
|
||||
List<NameValuePair> nVPairs = new ArrayList<NameValuePair>();
|
||||
//nVPairs.add(new BasicNameValuePair("batchSize", maxSizePerSync));
|
||||
|
@ -45,9 +44,9 @@ public class OwnCloudReaderMethods {
|
|||
nVPairs.add(new BasicNameValuePair("lastModified", String.valueOf(lastSync)));
|
||||
|
||||
|
||||
InputStream is = HttpJsonRequest.PerformJsonRequest(api.getItemUpdatedUrl(), nVPairs, api.getUsername(), api.getPassword(), act);
|
||||
InputStream is = HttpJsonRequest.PerformJsonRequest(api.getItemUpdatedUrl(), nVPairs, api.getUsername(), api.getPassword(), cont);
|
||||
|
||||
DatabaseConnection dbConn = new DatabaseConnection(act);
|
||||
DatabaseConnection dbConn = new DatabaseConnection(cont);
|
||||
try
|
||||
{
|
||||
return readJsonStream(is, new InsertItemIntoDatabase(dbConn));
|
||||
|
@ -58,7 +57,7 @@ public class OwnCloudReaderMethods {
|
|||
}
|
||||
|
||||
//"type": 1, // the type of the query (Feed: 0, Folder: 1, Starred: 2, All: 3)
|
||||
public static int GetItems(TAGS tag, Activity act, String offset, boolean getRead, String id, String type, API api) throws Exception
|
||||
public static int GetItems(TAGS tag, Context cont, String offset, boolean getRead, String id, String type, API api) throws Exception
|
||||
{
|
||||
List<NameValuePair> nVPairs = new ArrayList<NameValuePair>();
|
||||
nVPairs.add(new BasicNameValuePair("batchSize", maxSizePerSync));
|
||||
|
@ -79,9 +78,9 @@ public class OwnCloudReaderMethods {
|
|||
nVPairs.add(new BasicNameValuePair("getRead", "false"));
|
||||
|
||||
|
||||
InputStream is = HttpJsonRequest.PerformJsonRequest(api.getItemUrl(), nVPairs, api.getUsername(), api.getPassword(), act);
|
||||
InputStream is = HttpJsonRequest.PerformJsonRequest(api.getItemUrl(), nVPairs, api.getUsername(), api.getPassword(), cont);
|
||||
|
||||
DatabaseConnection dbConn = new DatabaseConnection(act);
|
||||
DatabaseConnection dbConn = new DatabaseConnection(cont);
|
||||
try
|
||||
{
|
||||
return readJsonStream(is, new InsertItemIntoDatabase(dbConn));
|
||||
|
@ -92,10 +91,10 @@ public class OwnCloudReaderMethods {
|
|||
}
|
||||
|
||||
|
||||
public static int GetFolderTags(Activity act, API api) throws Exception
|
||||
public static int GetFolderTags(Context cont, API api) throws Exception
|
||||
{
|
||||
InputStream is = HttpJsonRequest.PerformJsonRequest(api.getFolderUrl(), null, api.getUsername(), api.getPassword(), act);
|
||||
DatabaseConnection dbConn = new DatabaseConnection(act);
|
||||
InputStream is = HttpJsonRequest.PerformJsonRequest(api.getFolderUrl(), null, api.getUsername(), api.getPassword(), cont);
|
||||
DatabaseConnection dbConn = new DatabaseConnection(cont);
|
||||
int result = 0;
|
||||
try
|
||||
{
|
||||
|
@ -110,11 +109,11 @@ public class OwnCloudReaderMethods {
|
|||
return result;
|
||||
}
|
||||
|
||||
public static int GetFeeds(Activity act, API api) throws Exception
|
||||
public static int GetFeeds(Context cont, API api) throws Exception
|
||||
{
|
||||
InputStream inputStream = HttpJsonRequest.PerformJsonRequest(api.getFeedUrl() , null, api.getUsername(), api.getPassword(), act);
|
||||
InputStream inputStream = HttpJsonRequest.PerformJsonRequest(api.getFeedUrl() , null, api.getUsername(), api.getPassword(), cont);
|
||||
|
||||
DatabaseConnection dbConn = new DatabaseConnection(act);
|
||||
DatabaseConnection dbConn = new DatabaseConnection(cont);
|
||||
int result = 0;
|
||||
try {
|
||||
InsertFeedIntoDatabase ifid = new InsertFeedIntoDatabase(dbConn);
|
||||
|
@ -322,7 +321,7 @@ public class OwnCloudReaderMethods {
|
|||
}
|
||||
|
||||
|
||||
public static String GetVersionNumber(Activity act, String username, String password, String oc_root_path) throws Exception
|
||||
public static String GetVersionNumber(Context cont, String username, String password, String oc_root_path) throws Exception
|
||||
{
|
||||
if(oc_root_path.endsWith("/"))
|
||||
oc_root_path = oc_root_path.substring(0, oc_root_path.length() - 1);
|
||||
|
@ -330,7 +329,7 @@ public class OwnCloudReaderMethods {
|
|||
//Try APIv2
|
||||
try {
|
||||
String requestUrl = oc_root_path + OwnCloudConstants.ROOT_PATH_APIv2 + OwnCloudConstants.VERSION_PATH;
|
||||
InputStream is = HttpJsonRequest.PerformJsonRequest(requestUrl, null, username, password, act);
|
||||
InputStream is = HttpJsonRequest.PerformJsonRequest(requestUrl, null, username, password, cont);
|
||||
try {
|
||||
GetVersion gv = new GetVersion();
|
||||
readJsonStreamSimple(is, gv);
|
||||
|
@ -340,7 +339,7 @@ public class OwnCloudReaderMethods {
|
|||
}
|
||||
} catch(Exception ex) { //TODO GET HERE THE RIGHT EXCEPTION
|
||||
String requestUrl = oc_root_path + OwnCloudConstants.ROOT_PATH_APIv1 + OwnCloudConstants.VERSION_PATH;
|
||||
InputStream is = HttpJsonRequest.PerformJsonRequest(requestUrl, null, username, password, act);
|
||||
InputStream is = HttpJsonRequest.PerformJsonRequest(requestUrl, null, username, password, cont);
|
||||
try {
|
||||
GetVersion gv = new GetVersion();
|
||||
readJsonStreamSimple(is, gv);
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package de.luhmer.owncloudnewsreader.reader.owncloud;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.util.SparseArray;
|
||||
import de.luhmer.owncloudnewsreader.reader.AsyncTask_Reader;
|
||||
import de.luhmer.owncloudnewsreader.reader.FeedItemTags;
|
||||
|
@ -23,43 +22,42 @@ public class OwnCloud_Reader implements IReader {
|
|||
public void Start_AsyncTask_GetItems(int task_id,
|
||||
Activity context, OnAsyncTaskCompletedListener listener, FeedItemTags.TAGS tag) {
|
||||
setSyncRunning(true);
|
||||
AsyncTasksRunning.append(task_id, (AsyncTask_Reader) new AsyncTask_GetItems(task_id, context, new OnAsyncTaskCompletedListener[] { AsyncTask_finished, listener } ).execute(tag));
|
||||
AsyncTasksRunning.append(task_id, (AsyncTask_Reader) new AsyncTask_GetItems(task_id, context, new OnAsyncTaskCompletedListener[] { AsyncTask_finished, listener }, api).execute(tag));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Start_AsyncTask_GetOldItems(int task_id,
|
||||
Activity context, OnAsyncTaskCompletedListener listener, String feed_id, String folder_id) {
|
||||
setSyncRunning(true);
|
||||
AsyncTasksRunning.append(task_id, (AsyncTask_Reader) new AsyncTask_GetOldItems(task_id, context, new OnAsyncTaskCompletedListener[] { AsyncTask_finished, listener }, feed_id, folder_id).execute());
|
||||
AsyncTasksRunning.append(task_id, (AsyncTask_Reader) new AsyncTask_GetOldItems(task_id, context, new OnAsyncTaskCompletedListener[] { AsyncTask_finished, listener }, feed_id, folder_id, api).execute());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Start_AsyncTask_GetFolder(int task_id,
|
||||
Activity context, OnAsyncTaskCompletedListener listener) {
|
||||
setSyncRunning(true);
|
||||
AsyncTasksRunning.append(task_id, (AsyncTask_Reader) new AsyncTask_GetFolderTags(task_id, context, new OnAsyncTaskCompletedListener[] { AsyncTask_finished, listener } ).execute());
|
||||
AsyncTasksRunning.append(task_id, (AsyncTask_Reader) new AsyncTask_GetFolderTags(task_id, context, new OnAsyncTaskCompletedListener[] { AsyncTask_finished, listener }, api).execute());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Start_AsyncTask_GetFeeds(int task_id,
|
||||
Activity context, OnAsyncTaskCompletedListener listener) {
|
||||
setSyncRunning(true);
|
||||
AsyncTasksRunning.append(task_id, (AsyncTask_Reader) new AsyncTask_GetFeeds(task_id, context, new OnAsyncTaskCompletedListener[] { AsyncTask_finished, listener } ).execute());
|
||||
AsyncTasksRunning.append(task_id, (AsyncTask_Reader) new AsyncTask_GetFeeds(task_id, context, new OnAsyncTaskCompletedListener[] { AsyncTask_finished, listener }, api).execute());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Start_AsyncTask_PerformTagAction(int task_id,
|
||||
Activity context, OnAsyncTaskCompletedListener listener,
|
||||
List<String> itemIds, FeedItemTags.TAGS tag) {
|
||||
public void Start_AsyncTask_PerformItemStateChange(int task_id,
|
||||
Context context, OnAsyncTaskCompletedListener listener) {
|
||||
setSyncRunning(true);
|
||||
AsyncTasksRunning.append(task_id, (AsyncTask_Reader) new AsyncTask_PerformTagAction(task_id, context, new OnAsyncTaskCompletedListener[] { AsyncTask_finished, listener } ).execute(itemIds, tag));
|
||||
AsyncTasksRunning.append(task_id, (AsyncTask_Reader) new AsyncTask_PerformItemStateChange(task_id, context, new OnAsyncTaskCompletedListener[] { AsyncTask_finished, listener }, api).execute());
|
||||
}
|
||||
|
||||
|
||||
public void Start_AsyncTask_GetVersion(int task_id,
|
||||
Activity context, OnAsyncTaskCompletedListener listener, String username, String password) {
|
||||
Context context, OnAsyncTaskCompletedListener listener, String username, String password) {
|
||||
setSyncRunning(true);
|
||||
AsyncTasksRunning.append(task_id, (AsyncTask_Reader) new AsyncTask_GetApiVersion(task_id, context, username, password, new OnAsyncTaskCompletedListener[] { AsyncTask_finished, listener } ).execute());
|
||||
AsyncTasksRunning.append(task_id, (AsyncTask_Reader) new AsyncTask_GetApiVersion(task_id, context, username, password, new OnAsyncTaskCompletedListener[] { AsyncTask_finished, listener }).execute());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,7 +3,6 @@ package de.luhmer.owncloudnewsreader.reader.owncloud.apiv1;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import de.luhmer.owncloudnewsreader.SettingsActivity;
|
||||
import de.luhmer.owncloudnewsreader.reader.FeedItemTags.TAGS;
|
||||
|
@ -13,8 +12,8 @@ import de.luhmer.owncloudnewsreader.reader.owncloud.OwnCloudReaderMethods;
|
|||
|
||||
public class APIv1 extends API {
|
||||
|
||||
public APIv1(Activity act) {
|
||||
super(act);
|
||||
public APIv1(Context cont) {
|
||||
super(cont);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,7 +2,6 @@ package de.luhmer.owncloudnewsreader.reader.owncloud.apiv2;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import de.luhmer.owncloudnewsreader.SettingsActivity;
|
||||
import de.luhmer.owncloudnewsreader.reader.FeedItemTags.TAGS;
|
||||
|
@ -12,8 +11,8 @@ import de.luhmer.owncloudnewsreader.reader.owncloud.OwnCloudReaderMethods;
|
|||
|
||||
public class APIv2 extends API {
|
||||
|
||||
public APIv2(Activity act) {
|
||||
super(act);
|
||||
public APIv2(Context cont) {
|
||||
super(cont);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue