Only targets from user
This commit is contained in:
parent
995bf9d37e
commit
8c03324e96
|
@ -21,6 +21,8 @@ import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
@ -77,6 +79,7 @@ public class GNUAPI {
|
||||||
private String prefKeyOauthTokenT;
|
private String prefKeyOauthTokenT;
|
||||||
private APIResponse apiResponse;
|
private APIResponse apiResponse;
|
||||||
private Error APIError;
|
private Error APIError;
|
||||||
|
private String userId;
|
||||||
|
|
||||||
public enum accountPrivacy {
|
public enum accountPrivacy {
|
||||||
PUBLIC,
|
PUBLIC,
|
||||||
|
@ -89,11 +92,11 @@ public class GNUAPI {
|
||||||
accountPerPage = sharedpreferences.getInt(Helper.SET_ACCOUNTS_PER_PAGE, 40);
|
accountPerPage = sharedpreferences.getInt(Helper.SET_ACCOUNTS_PER_PAGE, 40);
|
||||||
notificationPerPage = sharedpreferences.getInt(Helper.SET_NOTIFICATIONS_PER_PAGE, 15);
|
notificationPerPage = sharedpreferences.getInt(Helper.SET_NOTIFICATIONS_PER_PAGE, 15);
|
||||||
this.prefKeyOauthTokenT = sharedpreferences.getString(PREF_KEY_OAUTH_TOKEN, null);
|
this.prefKeyOauthTokenT = sharedpreferences.getString(PREF_KEY_OAUTH_TOKEN, null);
|
||||||
|
userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||||
if( Helper.getLiveInstance(context) != null)
|
if( Helper.getLiveInstance(context) != null)
|
||||||
this.instance = Helper.getLiveInstance(context);
|
this.instance = Helper.getLiveInstance(context);
|
||||||
else {
|
else {
|
||||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
|
||||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(context));
|
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(context));
|
||||||
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||||
if( account == null) {
|
if( account == null) {
|
||||||
|
@ -1770,7 +1773,7 @@ public class GNUAPI {
|
||||||
* @param jsonArray JSONArray
|
* @param jsonArray JSONArray
|
||||||
* @return List<Status>
|
* @return List<Status>
|
||||||
*/
|
*/
|
||||||
private static List<Status> parseStatuses(Context context, JSONArray jsonArray){
|
private List<Status> parseStatuses(Context context, JSONArray jsonArray){
|
||||||
|
|
||||||
List<Status> statuses = new ArrayList<>();
|
List<Status> statuses = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
|
@ -1795,7 +1798,7 @@ public class GNUAPI {
|
||||||
* @return Status
|
* @return Status
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("InfiniteRecursion")
|
@SuppressWarnings("InfiniteRecursion")
|
||||||
public static Status parseStatuses(Context context, JSONObject resobj){
|
private Status parseStatuses(Context context, JSONObject resobj){
|
||||||
Status status = new Status();
|
Status status = new Status();
|
||||||
try {
|
try {
|
||||||
status.setId(resobj.get("id").toString());
|
status.setId(resobj.get("id").toString());
|
||||||
|
@ -1883,7 +1886,16 @@ public class GNUAPI {
|
||||||
status.setFavourited(false);
|
status.setFavourited(false);
|
||||||
}
|
}
|
||||||
if( resobj.has("friendica_activities") && resobj.getJSONObject("friendica_activities").has("like")){
|
if( resobj.has("friendica_activities") && resobj.getJSONObject("friendica_activities").has("like")){
|
||||||
status.setFavourited(resobj.getJSONObject("friendica_activities").getJSONArray("like").length() !=0);
|
status.setFavourited(false);
|
||||||
|
JSONArray jsonArray = resobj.getJSONObject("friendica_activities").getJSONArray("like");
|
||||||
|
for (int i = 0; i < jsonArray.length(); i++) {
|
||||||
|
JSONObject like = jsonArray.getJSONObject(i);
|
||||||
|
if( like.getString("id").equals(userId)) {
|
||||||
|
status.setFavourited(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
status.setMuted(false);
|
status.setMuted(false);
|
||||||
status.setPinned(false);
|
status.setPinned(false);
|
||||||
|
@ -2188,7 +2200,7 @@ public class GNUAPI {
|
||||||
* @param resobj JSONObject
|
* @param resobj JSONObject
|
||||||
* @return Account
|
* @return Account
|
||||||
*/
|
*/
|
||||||
public static Notification parseNotificationResponse(Context context, JSONObject resobj){
|
private Notification parseNotificationResponse(Context context, JSONObject resobj){
|
||||||
|
|
||||||
Notification notification = new Notification();
|
Notification notification = new Notification();
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue