Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.IOException;

import android.content.Context;
import android.graphics.Bitmap;

import android.graphics.BitmapFactory;

public class Main {

    private static Bitmap decodeBitmap(Context context, String frameName, int position) {
        try {
            switch (position) {
            case 0:
                return BitmapFactory.decodeStream(context.getAssets().open("frames/" + frameName + "/leftup.png"));
            case 1:
                return BitmapFactory.decodeStream(context.getAssets().open("frames/" + frameName + "/left.png"));
            case 2:
                return BitmapFactory
                        .decodeStream(context.getAssets().open("frames/" + frameName + "/leftdown.png"));
            case 3:
                return BitmapFactory.decodeStream(context.getAssets().open("frames/" + frameName + "/down.png"));
            case 4:
                return BitmapFactory
                        .decodeStream(context.getAssets().open("frames/" + frameName + "/rightdown.png"));
            case 5:
                return BitmapFactory.decodeStream(context.getAssets().open("frames/" + frameName + "/right.png"));
            case 6:
                return BitmapFactory.decodeStream(context.getAssets().open("frames/" + frameName + "/rightup.png"));
            case 7:
                return BitmapFactory.decodeStream(context.getAssets().open("frames/" + frameName + "/up.png"));
            default:
                return null;
            }
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }
}