This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git clone https://github.com/pivincii/Article-Activity-LifeCycle.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package blogging.pivincii.activitylifecycle; | |
import android.app.Activity; | |
import android.content.Intent; | |
import android.os.Bundle; | |
import android.util.Log; | |
import android.view.View; | |
public class MainActivity extends Activity { | |
private static String TAG = "LifeCycle " + MainActivity.class.getSimpleName(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package blogging.pivincii.activitylifecycle; | |
import android.app.Activity; | |
import android.os.Bundle; | |
import android.util.Log; | |
public class SecondActivity extends Activity { | |
private static String TAG = "LifeCycle " + SecondActivity.class.getSimpleName(); | |
@Override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.pivincii.blogging.activityresult | |
interface ActivityResultObservable { | |
fun addObserver(activityResultObserver: ActivityResultObserver) | |
fun removeObserver(activityResultObserver: ActivityResultObserver) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.pivincii.blogging | |
import android.content.Intent | |
import android.support.v7.app.AppCompatActivity | |
import com.pivincii.blogging.activityresult.ActivityResultObserver | |
import com.pivincii.blogging.activityresult.ActivityResultObservable | |
abstract class ActivityResultObservableActivity: AppCompatActivity(), ActivityResultObservable { | |
private val activityObserverList = mutableListOf<ActivityResultObserver>() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.pivincii.blogging | |
import android.app.Activity | |
import android.content.Context | |
import android.content.Intent | |
import android.util.AttributeSet | |
import android.widget.Button | |
import android.widget.FrameLayout | |
import android.widget.TextView | |
import com.pivincii.blogging.activityresult.ActivityResultObserver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.pivincii.blogging | |
import android.os.Bundle | |
class MainActivity : ActivityResultObservableActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.pivincii; | |
public class FirstThread extends Thread { | |
public void run() { | |
try { | |
System.out.println("Start " + currentThread().getName()); | |
sleep(5000); | |
System.out.println("End" + currentThread().getName()); | |
} catch (InterruptedException e) { | |
e.printStackTrace(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.pivincii; | |
public class CustomRunnable implements Runnable { | |
@Override | |
public void run() { | |
System.out.println("Start " + Thread.currentThread().getName()); | |
try { | |
Thread.sleep(5000); | |
} catch (InterruptedException e) { | |
e.printStackTrace(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.pivincii; | |
public class Main { | |
public static void main(String[] args) throws InterruptedException { | |
System.out.println("Start Main Thread"); | |
Thread t1 = new Thread(new Runnable() { | |
@Override | |
public void run() { | |
System.out.println("Start Thread 1"); |
OlderNewer