| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package com.example.renderthread; |
| 18 |
|
| 19 |
import android.app.Activity; |
| 20 |
import android.os.Bundle; |
| 21 |
import android.os.Process; |
| 22 |
import android.os.SystemClock; |
| 23 |
import android.view.View; |
| 24 |
import android.view.ViewGroup; |
| 25 |
|
| 26 |
public class SubActivity extends Activity { |
| 27 |
@Override |
| 28 |
protected void onCreate(Bundle savedInstanceState) { |
| 29 |
super.onCreate(savedInstanceState); |
| 30 |
long before = SystemClock.currentThreadTimeMillis(); |
| 31 |
setContentView(R.layout.activity_sub); |
| 32 |
getActionBar().setTitle("SubActivity"); |
| 33 |
|
| 34 |
while (SystemClock.currentThreadTimeMillis() - before < 100) { |
| 35 |
View v = new View(this, null); |
| 36 |
} |
| 37 |
} |
| 38 |
|
| 39 |
@Override |
| 40 |
protected void onResume() { |
| 41 |
super.onResume(); |
| 42 |
ViewGroup container = findViewById(R.id.my_container); |
| 43 |
int dx = getWindowManager().getDefaultDisplay().getWidth(); |
| 44 |
for (int i = 0; i < container.getChildCount(); i++) { |
| 45 |
View child = container.getChildAt(i); |
| 46 |
int dir = child.getId() == R.id.from_left ? 1 : -1; |
| 47 |
child.setTranslationX(dx * dir); |
| 48 |
child.animate().translationX(0).setDuration(MainActivity.DURATION); |
| 49 |
} |
| 50 |
View bg = findViewById(R.id.bg_container); |
| 51 |
bg.setAlpha(0f); |
| 52 |
bg.animate().alpha(1f).setDuration(MainActivity.DURATION); |
| 53 |
} |
| 54 |
|
| 55 |
@Override |
| 56 |
public void onBackPressed() { |
| 57 |
super.onBackPressed(); |
| 58 |
overridePendingTransition(0, 0); |
| 59 |
} |
| 60 |
} |