Example usage for android.graphics PixelFormat RGB_565

List of usage examples for android.graphics PixelFormat RGB_565

Introduction

In this page you can find the example usage for android.graphics PixelFormat RGB_565.

Prototype

int RGB_565

To view the source code for android.graphics PixelFormat RGB_565.

Click Source Link

Usage

From source file:org.telegram.ui.CountrySelectActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    try {//w  ww .ja  v a2  s  . co m
        BufferedReader reader = new BufferedReader(
                new InputStreamReader(getResources().getAssets().open("countries.txt")));
        String line;
        while ((line = reader.readLine()) != null) {
            String[] args = line.split(";");
            Country c = new Country();
            c.name = args[2];
            c.code = args[0];
            c.shortname = args[1];
            String n = c.name.substring(0, 1).toUpperCase();
            ArrayList<Country> arr = countries.get(n);
            if (arr == null) {
                arr = new ArrayList<Country>();
                countries.put(n, arr);
                sortedCountries.add(n);
            }
            arr.add(c);
        }
    } catch (Exception e) {
        FileLog.e("tmessages", e);
    }

    Collections.sort(sortedCountries, new Comparator<String>() {
        @Override
        public int compare(String lhs, String rhs) {
            return lhs.compareTo(rhs);
        }
    });

    for (ArrayList<Country> arr : countries.values()) {
        Collections.sort(arr, new Comparator<Country>() {
            @Override
            public int compare(Country country, Country country2) {
                return country.name.compareTo(country2.name);
            }
        });
    }

    setContentView(R.layout.country_select_layout);

    epmtyTextView = (TextView) findViewById(R.id.searchEmptyView);
    searchListViewAdapter = new SearchAdapter(this);

    listView = (PinnedHeaderListView) findViewById(R.id.listView);
    listView.setEmptyView(epmtyTextView);
    listView.setVerticalScrollBarEnabled(false);

    listView.setAdapter(listViewAdapter = new ListAdapter(this));
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            if (searching && searchWas) {
                if (i < searchResult.size()) {
                    Country c = searchResult.get(i);
                    Intent intent = new Intent();
                    intent.putExtra("country", c.name);
                    setResult(RESULT_OK, intent);
                    finish();
                }
            } else {
                int section = listViewAdapter.getSectionForPosition(i);
                int row = listViewAdapter.getPositionInSectionForPosition(i);
                if (section < sortedCountries.size()) {
                    String n = sortedCountries.get(section);
                    ArrayList<Country> arr = countries.get(n);
                    if (row < arr.size()) {
                        Country c = arr.get(row);
                        Intent intent = new Intent();
                        intent.putExtra("country", c.name);
                        setResult(RESULT_OK, intent);
                        finish();
                    }
                }
            }
        }
    });

    getWindow().setBackgroundDrawableResource(R.drawable.transparent);
    getWindow().setFormat(PixelFormat.RGB_565);
}

From source file:org.telegram.ui.ApplicationActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
    if (resourceId > 0) {
        Utilities.statusBarHeight = getResources().getDimensionPixelSize(resourceId);
    }//from ww  w .j a  v  a 2  s .  c  om

    NotificationCenter.Instance.postNotificationName(702, this);
    currentConnectionState = ConnectionsManager.Instance.connectionState;
    for (BaseFragment fragment : ApplicationLoader.fragmentsStack) {
        if (fragment.fragmentView != null) {
            ViewGroup parent = (ViewGroup) fragment.fragmentView.getParent();
            if (parent != null) {
                parent.removeView(fragment.fragmentView);
            }
            fragment.fragmentView = null;
        }
        fragment.parentActivity = this;
    }
    setContentView(R.layout.application_layout);
    NotificationCenter.Instance.addObserver(this, 1234);
    NotificationCenter.Instance.addObserver(this, 658);
    NotificationCenter.Instance.addObserver(this, 701);
    NotificationCenter.Instance.addObserver(this, 702);
    NotificationCenter.Instance.addObserver(this, 703);
    NotificationCenter.Instance.addObserver(this, GalleryImageViewer.needShowAllMedia);
    getSupportActionBar().setLogo(R.drawable.ab_icon_fixed2);

    statusView = getLayoutInflater().inflate(R.layout.updating_state_layout, null);
    statusBackground = statusView.findViewById(R.id.back_button_background);
    backStatusButton = statusView.findViewById(R.id.back_button);
    containerView = findViewById(R.id.container);
    statusText = (TextView) statusView.findViewById(R.id.status_text);
    statusBackground.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (ApplicationLoader.fragmentsStack.size() > 1) {
                onBackPressed();
            }
        }
    });

    if (ApplicationLoader.fragmentsStack.isEmpty()) {
        MessagesActivity fragment = new MessagesActivity();
        fragment.onFragmentCreate();
        ApplicationLoader.fragmentsStack.add(fragment);
    }

    boolean pushOpened = false;

    Integer push_user_id = (Integer) NotificationCenter.Instance.getFromMemCache("push_user_id", 0);
    Integer push_chat_id = (Integer) NotificationCenter.Instance.getFromMemCache("push_chat_id", 0);
    Integer push_enc_id = (Integer) NotificationCenter.Instance.getFromMemCache("push_enc_id", 0);
    Integer open_settings = (Integer) NotificationCenter.Instance.getFromMemCache("open_settings", 0);
    photoPath = (String) NotificationCenter.Instance.getFromMemCache(533);
    videoPath = (String) NotificationCenter.Instance.getFromMemCache(534);
    sendingText = (String) NotificationCenter.Instance.getFromMemCache(535);

    if (push_user_id != 0) {
        if (push_user_id == UserConfig.clientUserId) {
            open_settings = 1;
        } else {
            ChatActivity fragment = new ChatActivity();
            Bundle bundle = new Bundle();
            bundle.putInt("user_id", push_user_id);
            fragment.setArguments(bundle);
            if (fragment.onFragmentCreate()) {
                pushOpened = true;
                ApplicationLoader.fragmentsStack.add(fragment);
                getSupportFragmentManager().beginTransaction()
                        .replace(R.id.container, fragment, "chat" + Math.random()).commitAllowingStateLoss();
            }
        }
    } else if (push_chat_id != 0) {
        ChatActivity fragment = new ChatActivity();
        Bundle bundle = new Bundle();
        bundle.putInt("chat_id", push_chat_id);
        fragment.setArguments(bundle);
        if (fragment.onFragmentCreate()) {
            pushOpened = true;
            ApplicationLoader.fragmentsStack.add(fragment);
            getSupportFragmentManager().beginTransaction()
                    .replace(R.id.container, fragment, "chat" + Math.random()).commitAllowingStateLoss();
        }
    } else if (push_enc_id != 0) {
        ChatActivity fragment = new ChatActivity();
        Bundle bundle = new Bundle();
        bundle.putInt("enc_id", push_enc_id);
        fragment.setArguments(bundle);
        if (fragment.onFragmentCreate()) {
            pushOpened = true;
            ApplicationLoader.fragmentsStack.add(fragment);
            getSupportFragmentManager().beginTransaction()
                    .replace(R.id.container, fragment, "chat" + Math.random()).commitAllowingStateLoss();
        }
    }
    if (videoPath != null || photoPath != null || sendingText != null) {
        MessagesActivity fragment = new MessagesActivity();
        fragment.selectAlertString = R.string.ForwardMessagesTo;
        fragment.animationType = 1;
        Bundle args = new Bundle();
        args.putBoolean("onlySelect", true);
        fragment.setArguments(args);
        fragment.delegate = this;
        ApplicationLoader.fragmentsStack.add(fragment);
        fragment.onFragmentCreate();
        getSupportFragmentManager().beginTransaction().replace(R.id.container, fragment, fragment.getTag())
                .commitAllowingStateLoss();
        pushOpened = true;
    }
    if (open_settings != 0) {
        SettingsActivity fragment = new SettingsActivity();
        ApplicationLoader.fragmentsStack.add(fragment);
        fragment.onFragmentCreate();
        getSupportFragmentManager().beginTransaction().replace(R.id.container, fragment, "settings")
                .commitAllowingStateLoss();
        pushOpened = true;
    }
    if (!pushOpened) {
        BaseFragment fragment = ApplicationLoader.fragmentsStack
                .get(ApplicationLoader.fragmentsStack.size() - 1);
        getSupportFragmentManager().beginTransaction().replace(R.id.container, fragment, fragment.getTag())
                .commitAllowingStateLoss();
    }

    getWindow().setBackgroundDrawableResource(R.drawable.transparent);
    getWindow().setFormat(PixelFormat.RGB_565);
}

From source file:com.fishstix.dosboxfree.DBGLSurfaceView.java

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void setup(Context context) {
    mParent = (DBMain) context;/*from   w w w .j a  v a 2 s  . c  om*/
    //setRenderMode(RENDERMODE_WHEN_DIRTY);

    gestureScanner = new GestureDetector(context, new MyGestureDetector());
    mBitmapPaint = new Paint();
    mBitmapPaint.setFilterBitmap(true);
    mTextPaint = new Paint();
    mTextPaint.setTextSize(15 * getResources().getDisplayMetrics().density);
    mTextPaint.setTypeface(Typeface.DEFAULT_BOLD);
    mTextPaint.setTextAlign(Paint.Align.CENTER);
    mTextPaint.setStyle(Paint.Style.FILL);
    mTextPaint.setSubpixelText(false);

    mBitmap = Bitmap.createBitmap(DEFAULT_WIDTH, DEFAULT_HEIGHT, Bitmap.Config.RGB_565);

    //setEGLContextClientVersion(1);
    mRenderer = new OpenGLRenderer(mParent);
    mRenderer.setBitmap(mBitmap);
    setRenderer(mRenderer);
    setRenderMode(RENDERMODE_WHEN_DIRTY);
    if (mGPURendering) {
        requestRender();
    }

    mMouseThread = new DosBoxMouseThread();
    mMouseThread.setPriority(Thread.MIN_PRIORITY);
    mMouseThread.setRunning(true);
    mMouseThread.start();
    mVideoThread = new DosBoxVideoThread();
    mKeyHandler = new KeyHandler(this);

    // Receive keyboard events
    requestFocus();
    setFocusableInTouchMode(true);
    setFocusable(true);
    requestFocus();
    requestFocusFromTouch();

    getHolder().addCallback(this);
    getHolder().setFormat(PixelFormat.RGB_565);
    getHolder().setKeepScreenOn(true);
    if (Build.VERSION.SDK_INT >= 14) {
        setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
        setOnSystemUiVisibilityChangeListener(new MySystemUiVisibilityChangeListener());
    } else if (Build.VERSION.SDK_INT >= 11) {
        setSystemUiVisibility(View.STATUS_BAR_HIDDEN);
        setOnSystemUiVisibilityChangeListener(new MySystemUiVisibilityChangeListener());
    }
}

From source file:com.ll.myapplication.vitamio.widget.VideoView.java

/**
   * Must set before {@link #setVideoURI}
   * @param chroma//from  www .j  a va 2  s .  com
   */
  public void setVideoChroma(int chroma) {
      getHolder()
              .setFormat(chroma == MediaPlayer.VIDEOCHROMA_RGB565 ? PixelFormat.RGB_565 : PixelFormat.RGBA_8888); // PixelFormat.RGB_565
      mVideoChroma = chroma;
  }

From source file:org.videolan.vlc.gui.video.VideoPlayerActivity.java

@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.player);//from   w w w  . j a  v  a  2s .c om
    final MyHandler myHandler = new MyHandler();
    final LayoutInflater inflater = LayoutInflater.from(this);
    msgContainer = (LinearLayout) findViewById(R.id.msg_container);
    int current_locID;
    if (ActivityDevice.current_locID == -1)
        current_locID = ActivityShiPin.current_locID;
    else
        current_locID = ActivityDevice.current_locID;
    ArrayList<Integer> locIDList = MainActivity.locIDList;
    HashMap<Integer, ArrayList<Integer>> loc_devMap = MainActivity.loc_devMap;
    dev_typeMap = MainActivity.dev_typeMap;
    HashMap<Integer, String> dev_nameMap = MainActivity.dev_nameMap;
    Log.e("*****localID", String.valueOf(current_locID));
    if (current_locID != -1) {
        if (loc_devMap.containsKey(current_locID)) {
            devList = loc_devMap.get(current_locID);
            if (devList.size() != 0) {
                int sub = devList.get(0) - 0;
                final ArrayList<Integer> brokenList = new ArrayList<Integer>();
                brokenList.add(0);
                int i;
                for (i = 0; i < devList.size(); i++) {
                    int devID = devList.get(i);
                    Log.e("@@@@@@@@", String.valueOf(i));
                    if (sub != devID - i) {
                        brokenList.add(i);
                        sub = devID - i;
                    }
                    //int typeID=dev_typeMap.get(devID);
                    final View view = inflater.inflate(R.layout.senssor_msg, null);
                    TextView type = (TextView) view.findViewById(R.id.type);
                    TextView msg = (TextView) view.findViewById(R.id.msg);
                    type.setText(dev_nameMap.get(devID) + ":");
                    msgContainer.addView(view);

                }
                brokenList.add(i);
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        Log.e(">>>>>>>>>", "??");
                        String a = null;
                        try {
                            a = WebServiceUtil.getHd("sss", "njuptcloud");
                        } catch (Exception e1) {
                            // TODO Auto-generated catch block
                            //Toast.makeText(VideoPlayerActivity.this,"?a " , Toast.LENGTH_SHORT).show();
                            Log.e(">>>>>>>>>", "?a " + e1.getMessage());
                            e1.printStackTrace();

                        }
                        if (a != null) {
                            int i = 0;
                            List<String> msgList = new ArrayList<String>();
                            while (i < (brokenList.size() - 1)) {
                                try {
                                    //Toast.makeText(VideoPlayerActivity.this,"??... " , Toast.LENGTH_SHORT).show();
                                    msgList.addAll(WebServiceUtil.getMs(a, devList.get(brokenList.get(i)),
                                            devList.get(brokenList.get(i + 1) - 1)));
                                } catch (Exception e) {
                                    //Toast.makeText(VideoPlayerActivity.this,"?? " , Toast.LENGTH_SHORT).show();
                                    e.printStackTrace();
                                }
                                i++;
                            }
                            //                              List<String> resultList=new ArrayList<String>();
                            //                              resultList.add(object)
                            Message msg = new Message();
                            //Toast.makeText(VideoPlayerActivity.this,msgList.get(0) , Toast.LENGTH_SHORT).show();
                            msg.obj = msgList;
                            myHandler.sendMessage(msg);
                        } else {
                            Log.e(">>>>>>>", "??");
                            Message msg = new Message();
                            //Toast.makeText(VideoPlayerActivity.this,msgList.get(0) , Toast.LENGTH_SHORT).show();
                            msg.obj = null;
                            myHandler.sendMessage(msg);
                        }

                        //Toast.makeText(VideoPlayerActivity.this, "??", Toast.LENGTH_SHORT).show();
                    }
                }).start();
            }
        }
    }

    directionLayout = (LinearLayout) findViewById(R.id.direction_layout);

    left = (ImageButton) findViewById(R.id.left);
    left.setOnClickListener(directionListenr);
    bottom = (ImageButton) findViewById(R.id.bottom);
    bottom.setOnClickListener(directionListenr);
    top = (ImageButton) findViewById(R.id.top);
    top.setOnClickListener(directionListenr);
    right = (ImageButton) findViewById(R.id.right);
    right.setOnClickListener(directionListenr);

    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
    if (Util.isICSOrLater())
        getWindow().getDecorView().findViewById(android.R.id.content)
                .setOnSystemUiVisibilityChangeListener(new OnSystemUiVisibilityChangeListener() {
                    @Override
                    public void onSystemUiVisibilityChange(int visibility) {
                        if (visibility == mUiVisibility)
                            return;
                        setSurfaceSize(mVideoWidth, mVideoHeight, mVideoVisibleWidth, mVideoVisibleHeight,
                                mSarNum, mSarDen);
                        if (visibility == View.SYSTEM_UI_FLAG_VISIBLE && !mShowing) {
                            showOverlay();
                        }
                        mUiVisibility = visibility;
                    }
                });

    /** initialize Views an their Events */
    mOverlayHeader = findViewById(R.id.player_overlay_header);
    mOverlayHeader.setVisibility(View.GONE);
    mOverlayLock = findViewById(R.id.lock_overlay);
    mOverlayOption = findViewById(R.id.option_overlay);
    mOverlayProgress = findViewById(R.id.progress_overlay);
    mOverlayInterface = findViewById(R.id.interface_overlay);

    play_lay = (RelativeLayout) findViewById(R.id.play_lay);
    progress_lay = (LinearLayout) findViewById(R.id.progress_lay);

    /* header */
    mTitle = (TextView) findViewById(R.id.player_overlay_title);
    mSysTime = (TextView) findViewById(R.id.player_overlay_systime);
    mBattery = (TextView) findViewById(R.id.player_overlay_battery);

    // Position and remaining time
    mTime = (TextView) findViewById(R.id.player_overlay_time);
    mTime.setOnClickListener(mRemainingTimeListener);
    mLength = (TextView) findViewById(R.id.player_overlay_length);
    mLength.setOnClickListener(mRemainingTimeListener);

    // the info textView is not on the overlay
    mInfo = (TextView) findViewById(R.id.player_overlay_info);

    mEnableWheelbar = pref.getBoolean("enable_wheel_bar", false);
    mEnableBrightnessGesture = pref.getBoolean("enable_brightness_gesture", true);
    mScreenOrientation = Integer
            .valueOf(pref.getString("screen_orientation_value", "4" /*SCREEN_ORIENTATION_SENSOR*/));

    mControls = mEnableWheelbar ? new PlayerControlWheel(this) : new PlayerControlClassic(this);
    mControls.setOnPlayerControlListener(mPlayerControlListener);
    FrameLayout mControlContainer = (FrameLayout) findViewById(R.id.player_control);
    mControlContainer.addView((View) mControls);

    mAudioTrack = (ImageButton) findViewById(R.id.player_overlay_audio);
    mAudioTrack.setVisibility(View.GONE);
    mSubtitle = (ImageButton) findViewById(R.id.player_overlay_subtitle);
    mSubtitle.setVisibility(View.GONE);

    mHandler.postDelayed(new Runnable() {
        @Override
        public void run() {
            /*FIXME
             * The setTracksAndSubtitles method probably doesn't work in case of many many Tracks and Subtitles
             * Moreover, in a video stream, if Tracks & Subtitles change, they won't be updated
             */
            setESTrackLists();
        }
    }, 1500);

    mLock = (ImageButton) findViewById(R.id.lock_overlay_button);
    mLock.setOnClickListener(mLockListener);

    mSize = (ImageButton) findViewById(R.id.player_overlay_size);
    mSize.setOnClickListener(mSizeListener);

    snapshot_lay = (LinearLayout) findViewById(R.id.snapshot_lay);//??
    radio_onOrPause_lay = (LinearLayout) findViewById(R.id.radio_onOrPause_lay);//???        record_lay = (LinearLayout) findViewById(R.id.record_lay);//
    voice_lay = (LinearLayout) findViewById(R.id.voice_lay);//

    mSnapShot = (ImageButton) findViewById(R.id.snapshot_overlay_button);
    mSnapShot.setOnClickListener(mSnapShotListener);

    mRecord = (ImageButton) findViewById(R.id.record_overlay_button);
    mRecord.setOnClickListener(mRecordListener);

    //???        
    mRadio = (ImageButton) findViewById(R.id.radio_onOrPause_button);
    mRadio_tv = (TextView) findViewById(R.id.radio_onOrPause_tv);
    mRadio.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            if (mRadio.getBackground().getConstantState() == getResources().getDrawable(R.drawable.radio_on1)
                    .getConstantState()) {
                //?????
                if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) {
                    mRadio.setBackgroundDrawable(getResources().getDrawable(R.drawable.radio_pause));
                } else {
                    mRadio.setBackground(getResources().getDrawable(R.drawable.radio_pause));
                }
                mRadio_tv.setText("?");
                play();
            } else {
                //????
                if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) {
                    mRadio.setBackgroundDrawable(getResources().getDrawable(R.drawable.radio_on1));
                } else {
                    mRadio.setBackground(getResources().getDrawable(R.drawable.radio_on1));
                }
                mRadio_tv.setText("?");
                pause();
            }
        }
    });

    mAudioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
    mAudioMax = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
    //
    mVoice = (ImageButton) findViewById(R.id.voice_overlay_button);
    mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, mAudioMax, 0);
    mVoice.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            if (mVoice.getBackground().getConstantState() == getResources().getDrawable(R.drawable.voice_on)
                    .getConstantState()) {
                //??
                if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) {
                    mVoice.setBackgroundDrawable(getResources().getDrawable(R.drawable.voice_off));
                } else {
                    mVoice.setBackground(getResources().getDrawable(R.drawable.voice_off));
                }
                mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 0, 0);
            } else {
                //??
                if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) {
                    mVoice.setBackgroundDrawable(getResources().getDrawable(R.drawable.voice_on));
                } else {
                    mVoice.setBackground(getResources().getDrawable(R.drawable.voice_on));
                }
                mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, mAudioMax, 0);
            }
        }
    });

    mSurface = (SurfaceView) findViewById(R.id.player_surface);
    mSurfaceHolder = mSurface.getHolder();
    mSurfaceFrame = (FrameLayout) findViewById(R.id.player_surface_frame);
    mSurfaceFrame.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // TODO Auto-generated method stub
            if (MotionEvent.ACTION_DOWN == event.getAction()) {
                if (System.currentTimeMillis() - clickTime < 500) {
                    //??
                    if (mCurrentSize == SURFACE_4_3) {
                        //???
                        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
                    } else {
                        //??
                        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
                    }
                } else {
                    if (!mShowing) {
                        showOverlay();
                        mSurfaceFrame.setFocusable(false);
                    } else {
                        hideOverlay(true);
                    }
                }
                clickTime = System.currentTimeMillis();
                if (directionLayout.getVisibility() == View.INVISIBLE) {
                    directionLayout.setVisibility(View.VISIBLE);
                } else {
                    directionLayout.setVisibility(View.INVISIBLE);
                }
            }
            return true;
        }
    });

    mOrientationListener = new OrientationEventListener(this) {
        @Override
        public void onOrientationChanged(int rotation) {
            if (((rotation >= 0) && (rotation <= 45)) || (rotation >= 315)
                    || ((rotation >= 135) && (rotation <= 225))) {//portrait
                mCurrentOrient = true;
                if (mCurrentOrient != mScreenProtrait) {
                    mScreenProtrait = mCurrentOrient;
                    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
                    Log.d(TAG, "Screen orientation changed from Landscape to Portrait!");
                }
            } else if (((rotation > 45) && (rotation < 135)) || ((rotation > 225) && (rotation < 315))) {//landscape
                mCurrentOrient = false;
                if (mCurrentOrient != mScreenProtrait) {
                    mScreenProtrait = mCurrentOrient;
                    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
                    Log.d(TAG, "Screen orientation changed from Portrait to Landscape!");
                }
            }
        }
    };
    mOrientationListener.enable();

    int pitch;
    String chroma = pref.getString("chroma_format", "");
    if (Util.isGingerbreadOrLater() && chroma.equals("YV12")) {
        mSurfaceHolder.setFormat(ImageFormat.YV12);
        pitch = ImageFormat.getBitsPerPixel(ImageFormat.YV12) / 8;
    } else if (chroma.equals("RV16")) {
        mSurfaceHolder.setFormat(PixelFormat.RGB_565);
        PixelFormat info = new PixelFormat();
        PixelFormat.getPixelFormatInfo(PixelFormat.RGB_565, info);
        pitch = info.bytesPerPixel;
    } else {
        mSurfaceHolder.setFormat(PixelFormat.RGBX_8888);
        PixelFormat info = new PixelFormat();
        PixelFormat.getPixelFormatInfo(PixelFormat.RGBX_8888, info);
        pitch = info.bytesPerPixel;
    }
    mSurfaceAlign = 16 / pitch - 1;
    mSurfaceHolder.addCallback(mSurfaceCallback);

    mSeekbar = (SeekBar) findViewById(R.id.player_overlay_seekbar);
    mSeekbar.setOnSeekBarChangeListener(mSeekListener);

    mSwitchingView = false;
    mEndReached = false;

    // Clear the resume time, since it is only used for resumes in external
    // videos.
    SharedPreferences preferences = getSharedPreferences(PreferencesActivity.NAME, MODE_PRIVATE);
    SharedPreferences.Editor editor = preferences.edit();
    editor.putLong(PreferencesActivity.VIDEO_RESUME_TIME, -1);
    // Also clear the subs list, because it is supposed to be per session
    // only (like desktop VLC). We don't want the customs subtitle file
    // to persist forever with this video.
    editor.putString(PreferencesActivity.VIDEO_SUBTITLE_FILES, null);
    editor.commit();

    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_BATTERY_CHANGED);
    filter.addAction(VLCApplication.SLEEP_INTENT);
    registerReceiver(mReceiver, filter);

    try {
        mLibVLC = Util.getLibVlcInstance();
    } catch (LibVlcException e) {
        Log.d(TAG, "LibVLC initialisation failed");
        return;
    }

    EventHandler em = EventHandler.getInstance();
    em.addHandler(eventHandler);

    this.setVolumeControlStream(AudioManager.STREAM_MUSIC);

    // 100 is the value for screen_orientation_start_lock,??
    //        setRequestedOrientation(mScreenOrientation != 100
    //                ? mScreenOrientation
    //                : getScreenOrientation());

    //???
    //        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    //??
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}