Skip to content

Instantly share code, notes, and snippets.

@SlyNet
Created March 21, 2016 15:45
Show Gist options
  • Save SlyNet/e2d704f1f18c21b39c10 to your computer and use it in GitHub Desktop.
Save SlyNet/e2d704f1f18c21b39c10 to your computer and use it in GitHub Desktop.
public class AnimationActivily extends Activity {
private Bitmap log_imgs[];
private Bitmap tempBitmap;
private Handler uiHandler;
private ImageView logo_view;
int img_cnt = 1;
protected int _splashTime = 91;
Thread splashTread;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_animation_activily);
logo_view = (ImageView) findViewById(R.id.logo_view);
log_imgs = new Bitmap[91];
for (int i = 1; i <= 90; i++) {
get_Images_Assest(i, "logo_pngs");
}
logo_view.setImageBitmap(log_imgs[70]);
uiHandler = new Handler();
// thread for displaying the SplashScreen
splashTread = new Thread() {
@Override
public void run() {
try {
while (img_cnt < _splashTime) {
sleep(30);
if (img_cnt <= 90)
update_view(img_cnt);
img_cnt++;
}
} catch (InterruptedException e) {
// do nothing
} finally {
Intent i = new Intent(AnimationActivily.this,
MainActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(i);
AnimationActivily.this.finish();
// overridePendingTransition(R.anim.slide_in,
// R.anim.slide_out);
// *** Put this in another
// Activity***//overridePendingTransition(R.anim.slide_in,
// R.anim.slide_out);
}
}
};
splashTread.start();
}
public Bitmap tempImg;
private void get_Images_Assest(int cnt, String folder_name) {
try {
InputStream is = getAssets().open(
folder_name + "/" + "logo" + cnt + ".png");
if (tempImg != null) {
tempImg = null;
}
tempImg = BitmapFactory.decodeStream(is);
// tempBitmap = Bitmap.createScaledBitmap(tempImg,
// tempImg.getWidth() * 2, tempImg.getHeight() * 2, true);
log_imgs[cnt] = tempImg;
} catch (IOException e) {
e.printStackTrace();
}
}
public void update_view(final int cnt) {
uiHandler.post(new Runnable() {
public void run() {
try {
logo_view.setImageBitmap(log_imgs[cnt]);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public void onBackPressed() {
}
public void onDestroy() {
super.onDestroy();
for (int i = 1; i <= 90; i++) {
log_imgs[i].recycle();
}
log_imgs = null;
splashTread = null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment