mirror of
https://github.com/DrKLO/Telegram.git
synced 2025-03-15 20:08:00 +01:00
Fixed visualization of the overlay header when there is no connection
This commit is contained in:
parent
9094871824
commit
576ca6c23e
4 changed files with 61 additions and 13 deletions
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* This is the source code of Telegram for Android v. 1.4.x.
|
||||
* It is licensed under GNU GPL v. 2 or later.
|
||||
* You should have received a copy of the license in this archive (see LICENSE).
|
||||
*
|
||||
* Copyright Nikolai Kudashov, 2013-2014.
|
||||
*/
|
||||
package org.telegram.messenger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
public class ChangeAwareArrayList<T> extends ArrayList<T> {
|
||||
protected int oldModCount;
|
||||
|
||||
public ChangeAwareArrayList() {
|
||||
oldModCount = modCount;
|
||||
}
|
||||
|
||||
public ChangeAwareArrayList(int capacity) {
|
||||
super(capacity);
|
||||
oldModCount = modCount;
|
||||
}
|
||||
|
||||
public ChangeAwareArrayList(Collection<? extends T> collection) {
|
||||
super(collection);
|
||||
oldModCount = modCount;
|
||||
}
|
||||
|
||||
public boolean peekIsChanged() {
|
||||
return oldModCount != modCount;
|
||||
}
|
||||
|
||||
public boolean isChanged() {
|
||||
boolean ret = peekIsChanged();
|
||||
oldModCount = modCount;
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -83,6 +83,9 @@ public class TcpConnection extends ConnectionContext {
|
|||
public void connect() {
|
||||
if(!ConnectionsManager.isNetworkOnline() && !tryWithNoNetworkAnyway) {
|
||||
FileLog.d("tmessages", "Connection is not available, skipping task scheduling");
|
||||
|
||||
notifyConnectionError();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -155,6 +158,19 @@ public class TcpConnection extends ConnectionContext {
|
|||
});
|
||||
}
|
||||
|
||||
protected void notifyConnectionError() {
|
||||
connectionState = TcpConnectionState.TcpConnectionStageReconnecting;
|
||||
if (delegate != null) {
|
||||
final TcpConnectionDelegate finalDelegate = delegate;
|
||||
Utilities.stageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
finalDelegate.tcpConnectionClosed(TcpConnection.this);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void handleConnectionError(Exception e) {
|
||||
try {
|
||||
synchronized (timerSync) {
|
||||
|
@ -166,16 +182,8 @@ public class TcpConnection extends ConnectionContext {
|
|||
} catch (Exception e2) {
|
||||
FileLog.e("tmessages", e2);
|
||||
}
|
||||
connectionState = TcpConnectionState.TcpConnectionStageReconnecting;
|
||||
if (delegate != null) {
|
||||
final TcpConnectionDelegate finalDelegate = delegate;
|
||||
Utilities.stageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
finalDelegate.tcpConnectionClosed(TcpConnection.this);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
notifyConnectionError();
|
||||
|
||||
failedConnectionCount++;
|
||||
if (failedConnectionCount == 1) {
|
||||
|
|
|
@ -680,8 +680,8 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
|||
onFinish();
|
||||
}
|
||||
} else if (id == 703) {
|
||||
int state = (Integer)args[0];
|
||||
if (currentConnectionState != state) {
|
||||
if (fragmentsStack.isChanged()) {
|
||||
int state = (Integer)args[0];
|
||||
FileLog.e("tmessages", "switch to state " + state);
|
||||
currentConnectionState = state;
|
||||
updateActionBar();
|
||||
|
|
|
@ -31,6 +31,7 @@ import android.view.animation.Animation;
|
|||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import org.telegram.messenger.ChangeAwareArrayList;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.Utilities;
|
||||
|
@ -90,7 +91,7 @@ public class ActionBarActivity extends Activity {
|
|||
}
|
||||
}
|
||||
|
||||
public static ArrayList<BaseFragment> fragmentsStack = new ArrayList<BaseFragment>();
|
||||
public static ChangeAwareArrayList<BaseFragment> fragmentsStack = new ChangeAwareArrayList<BaseFragment>();
|
||||
|
||||
protected void onCreateFinish(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
|
Loading…
Add table
Reference in a new issue