Improves webview behavior
This commit is contained in:
parent
0939039a98
commit
0f5f712c6a
|
@ -20,7 +20,6 @@ import android.os.AsyncTask;
|
|||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -31,13 +30,10 @@ import android.widget.TextView;
|
|||
import android.widget.Toast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import fr.gouv.etalab.mastodon.activities.MainActivity;
|
||||
import fr.gouv.etalab.mastodon.client.APIResponse;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
||||
import fr.gouv.etalab.mastodon.drawers.NotificationsListAdapter;
|
||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
||||
|
@ -67,12 +63,9 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
|
|||
private SwipeRefreshLayout swipeRefreshLayout;
|
||||
private boolean swiped;
|
||||
private ListView lv_notifications;
|
||||
private DisplayNotificationsFragment displayNotificationsFragment;
|
||||
private TextView new_data;
|
||||
private String since_id;
|
||||
|
||||
public DisplayNotificationsFragment(){
|
||||
displayNotificationsFragment = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -148,6 +141,12 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
|
|||
}
|
||||
notificationsListAdapter = new NotificationsListAdapter(context,isOnWifi, behaviorWithAttachments, notifications);
|
||||
lv_notifications.setAdapter(notificationsListAdapter);
|
||||
if( notificationsTmp.size() > 0){
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
editor.putString(Helper.LAST_NOTIFICATION_MAX_ID + userId, notificationsTmp.get(0).getId());
|
||||
editor.apply();
|
||||
}
|
||||
if( notificationsTmp.size() > 0 && textviewNoAction.getVisibility() == View.VISIBLE)
|
||||
textviewNoAction.setVisibility(View.GONE);
|
||||
}
|
||||
|
@ -185,8 +184,6 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
|
|||
@Override
|
||||
public void onRetrieveNotifications(APIResponse apiResponse, String acct, String userId, boolean refreshData) {
|
||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
//UserId will be null here, so it needs to be retrieved from shared preferences
|
||||
userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
mainLoader.setVisibility(View.GONE);
|
||||
nextElementLoader.setVisibility(View.GONE);
|
||||
if( apiResponse.getError() != null){
|
||||
|
@ -200,7 +197,7 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
|
|||
}
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
List<Notification> notifications = apiResponse.getNotifications();
|
||||
since_id = apiResponse.getSince_id();
|
||||
String since_id = apiResponse.getSince_id();
|
||||
max_id = apiResponse.getMax_id();
|
||||
//The initial call comes from a classic tab refresh
|
||||
flag_loading = (max_id == null );
|
||||
|
@ -282,6 +279,11 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
|
|||
for(Notification not_tmp: notificationsTmp){
|
||||
notifications.add(not_tmp);
|
||||
}
|
||||
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
editor.putString(Helper.LAST_NOTIFICATION_MAX_ID + userId, notificationsTmp.get(0).getId());
|
||||
editor.apply();
|
||||
notificationsListAdapter = new NotificationsListAdapter(context,isOnWifi, behaviorWithAttachments, notifications);
|
||||
lv_notifications.setAdapter(notificationsListAdapter);
|
||||
if( textviewNoAction.getVisibility() == View.VISIBLE)
|
||||
|
|
|
@ -25,7 +25,6 @@ import android.support.v4.app.Fragment;
|
|||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -36,8 +35,6 @@ import android.widget.TextView;
|
|||
import android.widget.Toast;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import fr.gouv.etalab.mastodon.activities.MainActivity;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveRepliesAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.client.APIResponse;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||
|
@ -76,15 +73,12 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
private boolean isOnWifi;
|
||||
private int behaviorWithAttachments;
|
||||
private boolean showMediaOnly;
|
||||
private DisplayStatusFragment displayStatusFragment;
|
||||
private TextView new_data;
|
||||
private int positionSpinnerTrans;
|
||||
private String since_id;
|
||||
private boolean hideHeader;
|
||||
private String instanceValue;
|
||||
|
||||
public DisplayStatusFragment(){
|
||||
displayStatusFragment = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -228,6 +222,12 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
for(Status status: statusesTmp){
|
||||
statuses.add(status);
|
||||
}
|
||||
if( statusesTmp.size() > 0){
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
editor.putString(Helper.LAST_HOMETIMELINE_MAX_ID + userId, statusesTmp.get(0).getId());
|
||||
editor.apply();
|
||||
}
|
||||
if( statusesTmp.size() > 0 && textviewNoAction.getVisibility() == View.VISIBLE)
|
||||
textviewNoAction.setVisibility(View.GONE);
|
||||
statusListAdapter = new StatusListAdapter(context, type, targetedId, isOnWifi, behaviorWithAttachments, positionSpinnerTrans, statuses);
|
||||
|
@ -300,7 +300,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
return;
|
||||
}
|
||||
List<Status> statuses = apiResponse.getStatuses();
|
||||
since_id = apiResponse.getSince_id();
|
||||
String since_id = apiResponse.getSince_id();
|
||||
max_id = apiResponse.getMax_id();
|
||||
|
||||
flag_loading = (max_id == null );
|
||||
|
@ -385,6 +385,10 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
}
|
||||
if( textviewNoAction.getVisibility() == View.VISIBLE)
|
||||
textviewNoAction.setVisibility(View.GONE);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
editor.putString(Helper.LAST_HOMETIMELINE_MAX_ID + userId, statusesTmp.get(0).getId());
|
||||
editor.apply();
|
||||
statusListAdapter = new StatusListAdapter(context, type, targetedId, isOnWifi, behaviorWithAttachments, positionSpinnerTrans, statuses);
|
||||
lv_status.setAdapter(statusListAdapter);
|
||||
statusesTmp = new ArrayList<>();
|
||||
|
|
|
@ -52,6 +52,7 @@ import java.net.HttpURLConnection;
|
|||
import java.net.URL;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -390,6 +391,7 @@ public class StreamingService extends Service {
|
|||
|
||||
}else if ( event == EventStreaming.UPDATE){
|
||||
status = API.parseStatuses(getApplicationContext(), response);
|
||||
status.setReplies(new ArrayList<Status>()); //Force to don't display replies.
|
||||
max_id_home = status.getId();
|
||||
if( status.getContent() != null) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
|
@ -473,6 +475,7 @@ public class StreamingService extends Service {
|
|||
if( notify )
|
||||
notify = sharedpreferences.getBoolean(Helper.SET_NOTIF_HOMETIMELINE, true);
|
||||
}
|
||||
lastPreviousContent = status.getContent();
|
||||
}
|
||||
//All is good here for a notification, we will know check if it can be done depending of the hour
|
||||
if( notify)
|
||||
|
|
Loading…
Reference in New Issue