Initially show system UI for image

This commit is contained in:
Mario Danic 2017-01-23 23:40:41 +01:00 committed by AndyScherzinger
parent d8395d57b9
commit 1b6593103d
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
2 changed files with 4 additions and 45 deletions

View file

@ -28,9 +28,7 @@ import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
@ -104,8 +102,6 @@ public class PreviewImageActivity extends FileActivity implements
// ActionBar
ActionBar actionBar = getSupportActionBar();
updateActionBarTitleAndHomeButton(null);
actionBar.hide();
mFullScreenAnchorView = getWindow().getDecorView();
// to keep our UI controls visibility in line with system bars visibility
@ -164,43 +160,7 @@ public class PreviewImageActivity extends FileActivity implements
mRequestWaitingForBinder = true;
}
}
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
// Trigger the initial hide() shortly after the activity has been
// created, to briefly hint to the user that UI controls
// are available
delayedHide(INITIAL_HIDE_DELAY);
}
Handler mHideSystemUiHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
hideSystemUI(mFullScreenAnchorView);
getSupportActionBar().hide();
}
};
private void delayedHide(int delayMillis) {
mHideSystemUiHandler.removeMessages(0);
mHideSystemUiHandler.sendEmptyMessageDelayed(0, delayMillis);
}
/// handle Window Focus changes
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
// When the window loses focus (e.g. the action overflow is shown),
// cancel any pending hide action.
if (!hasFocus) {
mHideSystemUiHandler.removeMessages(0);
}
}
@Override
public void onStart() {
super.onStart();

View file

@ -168,7 +168,9 @@ public class PreviewImageFragment extends FileFragment {
view.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
((PreviewImageActivity) getActivity()).toggleFullScreen();
if (getActivity() != null && (getActivity() instanceof PreviewImageActivity)) {
((PreviewImageActivity) getActivity()).toggleFullScreen();
}
}
});
@ -551,9 +553,6 @@ public class PreviewImageFragment extends FileFragment {
}
private void showErrorMessage() {
if (getActivity() != null && (getActivity() instanceof PreviewImageActivity)) {
((PreviewImageActivity) getActivity()).toggleFullScreen();
}
setMessageForMultiList(mErrorMessageId, R.string.preview_sorry, R.drawable.file_image);
}
}