Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.lambda.imageviewer">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".activity_detail"
android:label="@string/title_activity_detail"
android:theme="@style/AppTheme.NoActionBar"></activity>
<activity
android:name=".MainActivity"
android:label="MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".FullscreenActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>

</manifest>
290 changes: 290 additions & 0 deletions FullscreenActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,290 @@
package com.lambda.imageviewer;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.content.Intent;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;


/**
* An example full-screen activity that shows and hides the system UI (i.e.
* status bar and navigation/system bar) with user interaction.
*/
public class FullscreenActivity extends AppCompatActivity {
// public static final int REQUEST_CODE = REQUEST_CODE;
/**
* Whether or not the system UI should be auto-hidden after
* {@link #AUTO_HIDE_DELAY_MILLIS} milliseconds.
*/
private int mTransitionCount; // 遷移した回数
private static final boolean AUTO_HIDE = true;

/**
* If {@link #AUTO_HIDE} is set, the number of milliseconds to wait after
* user interaction before hiding the system UI.
*/
private static final int AUTO_HIDE_DELAY_MILLIS = 3000;

/**
* Some older devices needs a small delay between UI widget updates
* and a change of the status and navigation bar.
*/
private static final int UI_ANIMATION_DELAY = 300;
private final Handler mHideHandler = new Handler();
private View mContentView;
private final Runnable mHidePart2Runnable = new Runnable() {
@SuppressLint("InlinedApi")
@Override
public void run() {
// Delayed removal of status and navigation bar

// Note that some of these constants are new as of API 16 (Jelly Bean)
// and API 19 (KitKat). It is safe to use them, as they are inlined
// at compile-time and do nothing on earlier devices.
mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
}
};
private View mControlsView;
private final Runnable mShowPart2Runnable = new Runnable() {
@Override
public void run() {
// Delayed display of UI elements
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.show();
}
mControlsView.setVisibility(View.VISIBLE);
}
};
private boolean mVisible;
private final Runnable mHideRunnable = new Runnable() {
@Override
public void run() {
hide();
}
};
/**
* Touch listener to use for in-layout UI controls to delay hiding the
* system UI. This is to prevent the jarring behavior of controls going away
* while interacting with activity UI.
*/
private final View.OnTouchListener mDelayHideTouchListener = new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if (AUTO_HIDE) {
delayedHide(AUTO_HIDE_DELAY_MILLIS);
}
return false;
}
};

@Override

protected void onStart() {

super.onStart();

Log.i("ActivityLifecycle", getLocalClassName() + " - onStart");
getIntent();


}


@Override

protected void onResume() {

super.onResume();

Log.i("ActivityLifecycle", getLocalClassName() + " - onResume");

}


// user interacting with app


@Override

protected void onPause() {

super.onPause();

Log.i("ActivityLifecycle", getLocalClassName() + " - onPause");

}


@Override

protected void onStop() {

super.onStop();

Log.i("ActivityLifecycle", getLocalClassName() + " - onStop");

}


@Override

protected void onDestroy() {

super.onDestroy();

Log.i("ActivityLifecycle", getLocalClassName() + " - onDestroy");

}




@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.i("ActivityLifecycle", getLocalClassName() + " - onCreate");
setContentView(R.layout.activity_fullscreen2);

mVisible = true;
mControlsView = findViewById(R.id.fullscreen_content_controls);
mContentView = findViewById(R.id.fullscreen_content);


Bundle extras =getIntent().getExtras();
if(extras!=null) {
TextView tv = findViewById(R.id.fullscreen_content);

String stringNew = extras.getString("STRING_I_NEED");

tv.setText(stringNew);
ImageView iv=findViewById(R.id.fullscreen_image);
iv.setImageURI(Uri.parse(stringNew));
}



// Set up the user interaction to manually show or hide the system UI.
mContentView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

ProcessToGoback();

}
});


// Upon interacting with UI controls, delay any scheduled hide()
// operations to prevent the jarring behavior of controls going away
// while interacting with the UI.
findViewById(R.id.dummy_button).setOnTouchListener(mDelayHideTouchListener);
}

@Override
public void onBackPressed()
{
// do stuff
super.onBackPressed();
ProcessToGoback();


}



@Override
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(100);
}

private void toggle() {
if (mVisible) {
hide();
} else {
show();
}
}

private void hide() {
// Hide UI first
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.hide();
}
mControlsView.setVisibility(View.GONE);
mVisible = false;

// Schedule a runnable to remove the status and navigation bar after a delay
mHideHandler.removeCallbacks(mShowPart2Runnable);
mHideHandler.postDelayed(mHidePart2Runnable, UI_ANIMATION_DELAY);
}

@SuppressLint("InlinedApi")
private void show() {
// Show the system bar
mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
mVisible = true;

// Schedule a runnable to display UI elements after a delay
mHideHandler.removeCallbacks(mHidePart2Runnable);
mHideHandler.postDelayed(mShowPart2Runnable, UI_ANIMATION_DELAY);
}

/**
* Schedules a call to hide() in delay milliseconds, canceling any
* previously scheduled calls.
*/
private void delayedHide(int delayMillis) {
mHideHandler.removeCallbacks(mHideRunnable);
mHideHandler.postDelayed(mHideRunnable, delayMillis);
}

private void ProcessToGoback(){

// Intent のインスタンスを取得する
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
// 渡したいデータとキーを指定する
intent.putExtra("COMING_BACK","I am back");
// 遷移先の画面を呼び出す
startActivity(intent);


}
}








56 changes: 56 additions & 0 deletions ImageData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.lambda.imageviewer;

import android.net.Uri;
import android.widget.TextView;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import java.io.Serializable;

class ImageData implements Serializable {
private String stringUri;
private TextView tV;
private int index;
ImageData(String stringUri, int index){
this.stringUri = stringUri;
this.index=index;


}

public void setIndex(int index){
this.index=index;

}

public int getIndex(){
return this.index;
}

public String getStringUri() {
return stringUri;
}

public void setStringUri(String stringUri) {
this.stringUri = stringUri;
}

public void setUri(Uri uriUri) {
this.stringUri=uriUri.toString();

}

public String toString(Uri uri) {
this.stringUri=uri.toString();
return super.toString();
}

public Uri getUri(){

Uri uriUri=Uri.parse(this.stringUri);

return uriUri;
}


}
Loading