Example usage for android.os Bundle getBoolean

List of usage examples for android.os Bundle getBoolean

Introduction

In this page you can find the example usage for android.os Bundle getBoolean.

Prototype

public boolean getBoolean(String key) 

Source Link

Document

Returns the value associated with the given key, or false if no mapping of the desired type exists for the given key.

Usage

From source file:com.krayzk9s.imgurholo.ui.SingleImageFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    final ImgurHoloActivity activity = (ImgurHoloActivity) getActivity();
    final SharedPreferences settings = activity.getApiCall().settings;
    sort = settings.getString("CommentSort", "Best");
    boolean newData = true;
    if (commentData != null) {
        newData = false;//from www. ja  v a2  s. c  om
    }

    mainView = inflater.inflate(R.layout.single_image_layout, container, false);
    String[] mMenuList = getResources().getStringArray(R.array.emptyList);
    if (commentAdapter == null)
        commentAdapter = new CommentAdapter(mainView.getContext());
    commentLayout = (ListView) mainView.findViewById(R.id.comment_thread);
    commentLayout.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    if (settings.getString("theme", MainActivity.HOLO_LIGHT).equals(MainActivity.HOLO_LIGHT))
        imageLayoutView = (LinearLayout) View.inflate(getActivity(), R.layout.image_view, null);
    else
        imageLayoutView = (LinearLayout) View.inflate(getActivity(), R.layout.dark_image_view, null);

    mPullToRefreshLayout = (PullToRefreshLayout) mainView.findViewById(R.id.ptr_layout);
    ActionBarPullToRefresh.from(getActivity())
            // Mark All Children as pullable
            .allChildrenArePullable()
            // Set the OnRefreshListener
            .listener(this)
            // Finally commit the setup to our PullToRefreshLayout
            .setup(mPullToRefreshLayout);
    if (savedInstanceState != null && newData) {
        imageData = savedInstanceState.getParcelable("imageData");
        inGallery = savedInstanceState.getBoolean("inGallery");
    }
    LinearLayout layout = (LinearLayout) imageLayoutView.findViewById(R.id.image_buttons);
    TextView imageDetails = (TextView) imageLayoutView.findViewById(R.id.single_image_details);
    layout.setVisibility(View.VISIBLE);
    ImageButton imageFullscreen = (ImageButton) imageLayoutView.findViewById(R.id.fullscreen);
    imageUpvote = (ImageButton) imageLayoutView.findViewById(R.id.rating_good);
    imageDownvote = (ImageButton) imageLayoutView.findViewById(R.id.rating_bad);
    ImageButton imageFavorite = (ImageButton) imageLayoutView.findViewById(R.id.rating_favorite);
    imageComment = (ImageButton) imageLayoutView.findViewById(R.id.comment);
    ImageButton imageUser = (ImageButton) imageLayoutView.findViewById(R.id.user);
    imageScore = (TextView) imageLayoutView.findViewById(R.id.single_image_score);
    TextView imageInfo = (TextView) imageLayoutView.findViewById(R.id.single_image_info);
    Log.d("imageData", imageData.getJSONObject().toString());
    if (imageData.getJSONObject().has("ups")) {
        imageUpvote.setVisibility(View.VISIBLE);
        imageDownvote.setVisibility(View.VISIBLE);
        imageScore.setVisibility(View.VISIBLE);
        imageComment.setVisibility(View.VISIBLE);
        ImageUtils.updateImageFont(imageData, imageScore);
    }
    imageInfo.setVisibility(View.VISIBLE);
    ImageUtils.updateInfoFont(imageData, imageInfo);
    imageUser.setVisibility(View.VISIBLE);
    imageFavorite.setVisibility(View.VISIBLE);
    try {
        if (!imageData.getJSONObject().has("account_url")
                || imageData.getJSONObject().getString("account_url").equals("null")
                || imageData.getJSONObject().getString("account_url").equals("[deleted]"))
            imageUser.setVisibility(View.GONE);
        if (!imageData.getJSONObject().has("vote")) {
            imageUpvote.setVisibility(View.GONE);
            imageDownvote.setVisibility(View.GONE);
        } else {
            if (imageData.getJSONObject().getString("vote") != null
                    && imageData.getJSONObject().getString("vote").equals("up"))
                imageUpvote.setImageResource(R.drawable.green_rating_good);
            else if (imageData.getJSONObject().getString("vote") != null
                    && imageData.getJSONObject().getString("vote").equals("down"))
                imageDownvote.setImageResource(R.drawable.red_rating_bad);
        }
        if (imageData.getJSONObject().getString("favorite") != null
                && imageData.getJSONObject().getBoolean("favorite"))
            imageFavorite.setImageResource(R.drawable.green_rating_favorite);
    } catch (JSONException e) {
        Log.e("Error!", e.toString());
    }
    imageFavorite.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ImageUtils.favoriteImage(singleImageFragment, imageData, (ImageButton) view, activity.getApiCall());
        }
    });
    imageUser.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ImageUtils.gotoUser(singleImageFragment, imageData);
        }
    });
    imageComment.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Activity activity = getActivity();
            final EditText newBody = new EditText(activity);
            newBody.setHint(R.string.body_hint_body);
            newBody.setLines(3);
            final TextView characterCount = new TextView(activity);
            characterCount.setText("140");
            LinearLayout commentReplyLayout = new LinearLayout(activity);
            newBody.addTextChangedListener(new TextWatcher() {
                @Override
                public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
                    //
                }

                @Override
                public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
                    characterCount.setText(String.valueOf(140 - charSequence.length()));
                }

                @Override
                public void afterTextChanged(Editable editable) {
                    for (int i = editable.length(); i > 0; i--) {
                        if (editable.subSequence(i - 1, i).toString().equals("\n"))
                            editable.replace(i - 1, i, "");
                    }
                }
            });
            commentReplyLayout.setOrientation(LinearLayout.VERTICAL);
            commentReplyLayout.addView(newBody);
            commentReplyLayout.addView(characterCount);
            new AlertDialog.Builder(activity).setTitle(R.string.dialog_comment_on_image_title)
                    .setView(commentReplyLayout)
                    .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {
                            if (newBody.getText() != null && newBody.getText().toString().length() < 141) {
                                HashMap<String, Object> commentMap = new HashMap<String, Object>();
                                try {
                                    commentMap.put("comment", newBody.getText().toString());
                                    commentMap.put("image_id", imageData.getJSONObject().getString("id"));
                                    Fetcher fetcher = new Fetcher(singleImageFragment, "3/comment/",
                                            ApiCall.POST, commentMap,
                                            ((ImgurHoloActivity) getActivity()).getApiCall(), POSTCOMMENT);
                                    fetcher.execute();
                                } catch (JSONException e) {
                                    Log.e("Error!", e.toString());
                                }
                            }
                        }
                    }).setNegativeButton(R.string.dialog_answer_cancel, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {
                            // Do nothing.
                        }
                    }).show();
        }
    });
    imageUpvote.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ImageUtils.upVote(singleImageFragment, imageData, imageUpvote, imageDownvote,
                    activity.getApiCall());
            ImageUtils.updateImageFont(imageData, imageScore);
        }
    });
    imageDownvote.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ImageUtils.downVote(singleImageFragment, imageData, imageUpvote, imageDownvote,
                    activity.getApiCall());
            ImageUtils.updateImageFont(imageData, imageScore);
        }
    });
    if (popupWindow != null) {
        popupWindow.dismiss();
    }
    popupWindow = new PopupWindow();
    imageFullscreen.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ImageUtils.fullscreen(singleImageFragment, imageData, popupWindow, mainView);
        }
    });
    ArrayAdapter<String> tempAdapter = new ArrayAdapter<String>(mainView.getContext(),
            R.layout.drawer_list_item, mMenuList);
    Log.d("URI", "YO I'M IN YOUR SINGLE FRAGMENT gallery:" + inGallery);
    imageView = (ImageView) imageLayoutView.findViewById(R.id.single_image_view);
    loadImage();
    TextView imageTitle = (TextView) imageLayoutView.findViewById(R.id.single_image_title);
    TextView imageDescription = (TextView) imageLayoutView.findViewById(R.id.single_image_description);

    try {
        String size = String
                .valueOf(NumberFormat.getIntegerInstance()
                        .format(imageData.getJSONObject().getInt(ImgurHoloActivity.IMAGE_DATA_WIDTH)))
                + "x"
                + NumberFormat.getIntegerInstance()
                        .format(imageData.getJSONObject().getInt(ImgurHoloActivity.IMAGE_DATA_HEIGHT))
                + " (" + NumberFormat.getIntegerInstance()
                        .format(imageData.getJSONObject().getInt(ImgurHoloActivity.IMAGE_DATA_SIZE))
                + "B)";
        String initial = imageData.getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_TYPE) + " "
                + Html.fromHtml("&#8226;") + " " + size + " " + Html.fromHtml("&#8226;") + " " + "Views: "
                + NumberFormat.getIntegerInstance()
                        .format(imageData.getJSONObject().getInt(ImgurHoloActivity.IMAGE_DATA_VIEWS));
        imageDetails.setText(initial);
        Log.d("imagedata", imageData.getJSONObject().toString());
        if (!imageData.getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_TITLE).equals("null"))
            imageTitle.setText(imageData.getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_TITLE));
        else
            imageTitle.setVisibility(View.GONE);
        if (!imageData.getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_DESCRIPTION).equals("null")) {
            imageDescription
                    .setText(imageData.getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_DESCRIPTION));
            imageDescription.setVisibility(View.VISIBLE);
        } else
            imageDescription.setVisibility(View.GONE);
        commentLayout.addHeaderView(imageLayoutView);
        commentLayout.setAdapter(tempAdapter);
    } catch (JSONException e) {
        Log.e("Text Error!", e.toString());
    }
    if ((savedInstanceState == null || commentData == null) && newData) {
        commentData = new JSONParcelable();
        getComments();
        commentLayout.setAdapter(commentAdapter);
    } else if (newData) {
        commentArray = savedInstanceState.getParcelableArrayList("commentData");
        commentAdapter.addAll(commentArray);
        commentLayout.setAdapter(commentAdapter);
        commentAdapter.notifyDataSetChanged();
    } else if (commentArray != null) {
        commentAdapter.addAll(commentArray);
        commentLayout.setAdapter(commentAdapter);
        commentAdapter.notifyDataSetChanged();
    }
    return mainView;
}

From source file:com.achep.base.ui.activities.SettingsActivity.java

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

    // Should happen before any call to getIntent()
    getMetaData();/*from w ww .ja va 2  s  . c o m*/

    final Intent intent = getIntent();
    if (intent.hasExtra(EXTRA_UI_OPTIONS)) {
        getWindow().setUiOptions(intent.getIntExtra(EXTRA_UI_OPTIONS, 0));
    }

    // Getting Intent properties can only be done after the super.onCreate(...)
    final String initialFragmentName = intent.getStringExtra(EXTRA_SHOW_FRAGMENT);

    mIsShortcut = isShortCutIntent(intent) || isLikeShortCutIntent(intent)
            || intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SHORTCUT, false);

    final ComponentName cn = intent.getComponent();
    final String className = cn.getClassName();

    boolean isShowingDashboard = className.equals(Settings2.class.getName());

    // This is a "Sub Settings" when:
    // - this is a real SubSettings
    // - or :settings:show_fragment_as_subsetting is passed to the Intent
    final boolean isSubSettings = className.equals(SubSettings.class.getName())
            || intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, false);

    // If this is a sub settings, then apply the SubSettings Theme for the ActionBar content insets
    if (isSubSettings) {
        // Check also that we are not a Theme Dialog as we don't want to override them
        /*
        final int themeResId = getTheme(). getThemeResId();
        if (themeResId != R.style.Theme_DialogWhenLarge &&
            themeResId != R.style.Theme_SubSettingsDialogWhenLarge) {
        setTheme(R.style.Theme_SubSettings);
        }
        */
    }

    setContentView(R.layout.settings_main_dashboard);

    mContent = (ViewGroup) findViewById(android.R.id.content);

    getSupportFragmentManager().addOnBackStackChangedListener(this);

    if (savedState != null) {
        // We are restarting from a previous saved state; used that to initialize, instead
        // of starting fresh.

        setTitleFromIntent(intent);

        ArrayList<DashboardCategory> categories = savedState.getParcelableArrayList(SAVE_KEY_CATEGORIES);
        if (categories != null) {
            mCategories.clear();
            mCategories.addAll(categories);
            setTitleFromBackStack();
        }

        mDisplayHomeAsUpEnabled = savedState.getBoolean(SAVE_KEY_SHOW_HOME_AS_UP);
    } else {
        if (!isShowingDashboard) {
            mDisplayHomeAsUpEnabled = isSubSettings;
            setTitleFromIntent(intent);

            Bundle initialArguments = intent.getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS);
            switchToFragment(initialFragmentName, initialArguments, true, false, mInitialTitleResId,
                    mInitialTitle, false);
        } else {
            mDisplayHomeAsUpEnabled = false;
            mInitialTitleResId = R.string.app_name;
            switchToFragment(DashboardFragment.class.getName(), null, false, false, mInitialTitleResId,
                    mInitialTitle, false);
        }
    }

    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(mDisplayHomeAsUpEnabled);
        actionBar.setHomeButtonEnabled(mDisplayHomeAsUpEnabled);
    }
}

From source file:com.aimfire.gallery.GalleryActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    supportRequestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_gallery);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    /*// ww  w  . ja  v a2 s.  c  o m
     * load display mode, swap and color mode that were last used
     */
    loadDisplayPrefs();

    /*
     * show overflow button even if we have a physical menu button
     */
    forceOverflowButton();

    /*
     * Obtain the FirebaseAnalytics instance.
     */
    mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);

    /*
     * initialize the view pager with current media we have
     */
    initViewPager();

    mNoMedia = (ImageView) findViewById(R.id.no_media_bg);
    mNoMedia.setOnTouchListener(otl);

    mCardboardButton = (FloatingActionButton) findViewById(R.id.cardboardFAB);
    mCardboardButton.setOnClickListener(oclCardboard);

    if (savedInstanceState != null) {
        mIsMyMedia = savedInstanceState.getBoolean(KEY_PAGER_MY_MEDIA);
        updateViewPager(null, savedInstanceState.getInt(KEY_PAGER_POSITION), -1);
    } else {
        /*
         * parse the intent
         */
        Intent intent = getIntent();
        parseIntent(intent);
    }

    showHideView();

    /*
     * initial command to hide action bar
     */
    if (AUTO_HIDE) {
        delayedHide(AUTO_HIDE_DELAY_SHORT_MILLIS);
    }
}

From source file:cgeo.geocaching.CacheListActivity.java

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

    setTheme();//  ww w.  j  a  va  2s.  c o  m

    setContentView(R.layout.cacheslist_activity);

    // get parameters
    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        type = Intents.getListType(getIntent());
        coords = extras.getParcelable(Intents.EXTRA_COORDS);
    } else {
        extras = new Bundle();
    }
    if (isInvokedFromAttachment()) {
        type = CacheListType.OFFLINE;
        if (coords == null) {
            coords = Geopoint.ZERO;
        }
    }
    if (type == CacheListType.NEAREST) {
        coords = Sensors.getInstance().currentGeo().getCoords();
    }

    setTitle(title);

    // Check whether we're recreating a previously destroyed instance
    if (savedInstanceState != null) {
        // Restore value of members from saved state
        currentFilter = savedInstanceState.getParcelable(STATE_FILTER);
        currentInverseSort = savedInstanceState.getBoolean(STATE_INVERSE_SORT);
        type = CacheListType.values()[savedInstanceState.getInt(STATE_LIST_TYPE, type.ordinal())];
        listId = savedInstanceState.getInt(STATE_LIST_ID);
    }

    initAdapter();

    prepareFilterBar();

    if (type.canSwitch) {
        initActionBarSpinner();
    }

    currentLoader = (AbstractSearchLoader) getSupportLoaderManager().initLoader(type.getLoaderId(), extras,
            this);

    // init
    if (CollectionUtils.isNotEmpty(cacheList)) {
        // currentLoader can be null if this activity is created from a map, as onCreateLoader() will return null.
        if (currentLoader != null && currentLoader.isStarted()) {
            showFooterLoadingCaches();
        } else {
            showFooterMoreCaches();
        }
    }

    if (isInvokedFromAttachment()) {
        listNameMemento.rememberTerm(extras.getString(Intents.EXTRA_NAME));
        importGpxAttachement();
    }
}

From source file:com.dycody.android.idealnote.DetailFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mainActivity = (MainActivity) getActivity();

    prefs = mainActivity.prefs;/*from   www. jav  a2s .c om*/

    mainActivity.getSupportActionBar().setDisplayShowTitleEnabled(false);
    mainActivity.getToolbar().setNavigationOnClickListener(v -> navigateUp());

    // Force the navigation drawer to stay opened if tablet mode is on, otherwise has to stay closed
    if (NavigationDrawerFragment.isDoublePanelActive()) {
        mainActivity.getDrawerLayout().setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN);
    } else {
        mainActivity.getDrawerLayout().setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
    }

    // Restored temp note after orientation change
    if (savedInstanceState != null) {
        noteTmp = savedInstanceState.getParcelable("noteTmp");
        note = savedInstanceState.getParcelable("note");
        noteOriginal = savedInstanceState.getParcelable("noteOriginal");
        attachmentUri = savedInstanceState.getParcelable("attachmentUri");
        orientationChanged = savedInstanceState.getBoolean("orientationChanged");
    }

    // Added the sketched image if present returning from SketchFragment
    if (mainActivity.sketchUri != null) {
        Attachment mAttachment = new Attachment(mainActivity.sketchUri, Constants.MIME_TYPE_SKETCH);
        addAttachment(mAttachment);
        mainActivity.sketchUri = null;
        // Removes previous version of edited image
        if (sketchEdited != null) {
            noteTmp.getAttachmentsList().remove(sketchEdited);
            sketchEdited = null;
        }
    }

    init();

    setHasOptionsMenu(true);
    setRetainInstance(false);
}

From source file:com.aimfire.demo.CameraActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    if (BuildConfig.DEBUG)
        Log.d(TAG, "create CameraActivity");

    checkPreferences();/*from w  w w.  ja  v  a  2  s . co  m*/

    /*
     *  keep the screen on until we turn off the flag 
     */
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_camera);

    /*
     * Obtain the FirebaseAnalytics instance.
     */
    mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);

    /*
     * disable nfc push
     */
    NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this);
    if (nfcAdapter != null)
        nfcAdapter.setNdefPushMessage(null, this);

    /*
     * get the natural orientation of this device. need to be called before
     * we fix the display orientation
     */
    mNaturalOrientation = getDeviceDefaultOrientation();

    /*
     * force CameraActivity in landscape because it is the natural 
     * orientation of the camera sensor
     */
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    mLandscapeOrientation = getDeviceLandscapeOrientation();

    Bundle extras = getIntent().getExtras();
    if (extras == null) {
        if (BuildConfig.DEBUG)
            Log.e(TAG, "onCreate: error create CameraActivity, wrong parameter");
        finish();
        return;
    }

    /*
     *  make sure we have camera
     */
    if (!checkCameraHardware(this)) {
        if (BuildConfig.DEBUG)
            Log.e(TAG, "onCreate: error create CameraActivity, cannot find camera!!!");
        finish();
        return;
    }

    mIsLeft = extras.getBoolean(MainConsts.EXTRA_ISLEFT);

    mView3DButton = (ImageButton) findViewById(R.id.view3D_button);
    mExitButton = (ImageButton) findViewById(R.id.exit_button);
    mCaptureButton = (ImageButton) findViewById(R.id.capture_button);
    mPvButton = (ImageButton) findViewById(R.id.switch_photo_video_button);
    mFbButton = (ImageButton) findViewById(R.id.switch_front_back_button);
    mLevelButton = (Button) findViewById(R.id.level_button);
    mModeButton = (ImageButton) findViewById(R.id.mode_button);

    if (mIsLeft) {
        mCaptureButton.setImageResource(R.drawable.ic_photo_camera_black_24dp);
    } else {
        mCaptureButton.setVisibility(View.INVISIBLE);

        mPvButton.setVisibility(View.INVISIBLE);
        mFbButton.setVisibility(View.INVISIBLE);
    }

    mView3DButton.setOnClickListener(oclView3D);
    mExitButton.setOnClickListener(oclExit);
    mPvButton.setOnClickListener(oclPV);
    mFbButton.setOnClickListener(oclFB);
    mCaptureButton.setOnClickListener(oclCapture);

    /*
     * we could get here in two ways: 1) directly after MainActivity ->
     * AimfireService sync with remote device. 2) we could get here 
     * because of a switch from video to photo mode. 
     * 
     * mSyncTimeUs is determined by AudioContext. each device 
     * calculates it, and they correspond to the same absolute moment 
     * in time
     */
    mSyncTimeUs = extras.getLong(MainConsts.EXTRA_SYNCTIME, -1);

    /*
     * start camera client object in a dedicated thread
     */
    mCameraClient = new CameraClient(Camera.CameraInfo.CAMERA_FACING_BACK, PHOTO_DIMENSION[0],
            PHOTO_DIMENSION[1]);

    /*
     * create our SurfaceView for preview 
     */
    mPreview = new CameraPreview(this);
    mPreviewLayout = (AspectFrameLayout) findViewById(R.id.cameraPreview_frame);
    mPreviewLayout.addView(mPreview);
    mPreviewLayout.setOnTouchListener(otl);
    if (BuildConfig.DEBUG)
        Log.d(TAG, "add camera preview view");

    mShutterSoundPlayer = MediaPlayer.create(this, Uri.parse("file:///system/media/audio/ui/camera_click.ogg"));

    /*
     * place UI controls at their initial, default orientation
     */
    adjustUIControls(0);

    /*
     * load the latest thumbnail to the view3D button
     */
    loadCurrThumbnail();

    /*
     * initializes AimfireService, and bind to it
     */
    mAimfireServiceConn = new AimfireServiceConn(this);

    /*
     * binding doesn't happen until later. wait for it to happen in another 
     * thread and connect to p2p peer if necessary
     */
    (new Thread(mAimfireServiceInitTask)).start();

    if (ADD_LOGO) {
        /*
         * init our logo that will be embedded in processed photos
         */
        AssetManager assetManager = getAssets();
        p.getInstance().a(assetManager, MainConsts.MEDIA_3D_RAW_PATH, "logo.png");
    }

    /*
     * register for AimfireService message broadcast
     */
    LocalBroadcastManager.getInstance(this).registerReceiver(mAimfireServiceMsgReceiver,
            new IntentFilter(MainConsts.AIMFIRE_SERVICE_MESSAGE));

    /*
     * register for intents sent by the media processor service
     */
    LocalBroadcastManager.getInstance(this).registerReceiver(mPhotoProcessorMsgReceiver,
            new IntentFilter(MainConsts.PHOTO_PROCESSOR_MESSAGE));
}

From source file:com.github.chenxiaolong.dualbootpatcher.switcher.InAppFlashingFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    if (savedInstanceState != null) {
        ArrayList<MbtoolAction> savedActions = savedInstanceState.getParcelableArrayList(EXTRA_PENDING_ACTIONS);
        mPendingActions.addAll(savedActions);
    }/*from  w  w w.j av  a  2 s .  com*/

    mProgressBar = (ProgressBar) getActivity().findViewById(R.id.card_list_loading);
    RecyclerView cardListView = (RecyclerView) getActivity().findViewById(R.id.card_list);

    mAdapter = new PendingActionCardAdapter(getActivity(), mPendingActions);
    cardListView.setHasFixedSize(true);
    cardListView.setAdapter(mAdapter);

    DragSwipeItemTouchCallback itemTouchCallback = new DragSwipeItemTouchCallback(this);
    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(itemTouchCallback);
    itemTouchHelper.attachToRecyclerView(cardListView);

    LinearLayoutManager llm = new LinearLayoutManager(getActivity());
    llm.setOrientation(LinearLayoutManager.VERTICAL);
    cardListView.setLayoutManager(llm);

    final FloatingActionMenu fabMenu = (FloatingActionMenu) getActivity().findViewById(R.id.fab_add_item_menu);
    FloatingActionButton fabAddPatchedFile = (FloatingActionButton) getActivity()
            .findViewById(R.id.fab_add_patched_file);
    FloatingActionButton fabAddBackup = (FloatingActionButton) getActivity().findViewById(R.id.fab_add_backup);

    fabAddPatchedFile.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            addPatchedFile();
            fabMenu.close(true);
        }
    });
    fabAddBackup.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            addBackup();
            fabMenu.close(true);
        }
    });

    if (savedInstanceState != null) {
        mSelectedUri = savedInstanceState.getParcelable(EXTRA_SELECTED_URI);
        mSelectedUriFileName = savedInstanceState.getString(EXTRA_SELECTED_URI_FILE_NAME);
        mSelectedBackupDirUri = savedInstanceState.getParcelable(EXTRA_SELECTED_BACKUP_DIR_URI);
        mSelectedBackupName = savedInstanceState.getString(EXTRA_SELECTED_BACKUP_NAME);
        mSelectedBackupTargets = savedInstanceState.getStringArray(EXTRA_SELECTED_BACKUP_TARGETS);
        mSelectedRomId = savedInstanceState.getString(EXTRA_SELECTED_ROM_ID);
        mZipRomId = savedInstanceState.getString(EXTRA_ZIP_ROM_ID);
        mAddType = (Type) savedInstanceState.getSerializable(EXTRA_ADD_TYPE);
        mTaskIdVerifyZip = savedInstanceState.getInt(EXTRA_TASK_ID_VERIFY_ZIP);
        mQueryingMetadata = savedInstanceState.getBoolean(EXTRA_QUERYING_METADATA);
    }

    try {
        mActivityCallback = (OnReadyStateChangedListener) getActivity();
    } catch (ClassCastException e) {
        throw new ClassCastException(getActivity().toString() + " must implement OnReadyStateChangedListener");
    }

    mActivityCallback.onReady(!mPendingActions.isEmpty());

    mPrefs = getActivity().getSharedPreferences("settings", 0);

    if (savedInstanceState == null) {
        boolean shouldShow = mPrefs.getBoolean(PREF_SHOW_FIRST_USE_DIALOG, true);
        if (shouldShow) {
            FirstUseDialog d = FirstUseDialog.newInstance(this, R.string.in_app_flashing_title,
                    R.string.in_app_flashing_dialog_first_use);
            d.show(getFragmentManager(), CONFIRM_DIALOG_FIRST_USE);
        }
    }

    getActivity().getLoaderManager().initLoader(0, null, this);
}

From source file:com.amaze.carbonfilemanager.fragments.ZipViewer.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    Sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
    s = getArguments().getString(KEY_PATH);
    Uri uri = Uri.parse(s);/*from w  w  w  . j a  va2s. c  o  m*/
    f = new File(uri.getPath());
    mToolbarContainer = getActivity().findViewById(R.id.lin);
    mToolbarContainer.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            if (stopAnims) {
                if ((!rarAdapter.stoppedAnimation)) {
                    stopAnim();
                }
                rarAdapter.stoppedAnimation = true;

            }
            stopAnims = false;
            return false;
        }
    });
    hidemode = Sp.getInt("hidemode", 0);
    listView.setVisibility(View.VISIBLE);
    mLayoutManager = new LinearLayoutManager(getActivity());
    listView.setLayoutManager(mLayoutManager);
    res = getResources();
    mainActivity.supportInvalidateOptionsMenu();
    if (utilsProvider.getAppTheme().equals(AppTheme.DARK))
        rootView.setBackgroundColor(Utils.getColor(getContext(), R.color.holo_dark_background));
    else
        listView.setBackgroundColor(Utils.getColor(getContext(), android.R.color.background_light));

    gobackitem = Sp.getBoolean("goBack_checkbox", false);
    coloriseIcons = Sp.getBoolean("coloriseIcons", true);
    Calendar calendar = Calendar.getInstance();
    showSize = Sp.getBoolean("showFileSize", false);
    showLastModified = Sp.getBoolean("showLastModified", true);
    showDividers = Sp.getBoolean("showDividers", true);
    year = ("" + calendar.get(Calendar.YEAR)).substring(2, 4);
    skin = mainActivity.getColorPreference().getColorAsString(ColorUsage.PRIMARY);
    accentColor = mainActivity.getColorPreference().getColorAsString(ColorUsage.ACCENT);
    iconskin = mainActivity.getColorPreference().getColorAsString(ColorUsage.ICON_SKIN);

    //mainActivity.findViewById(R.id.buttonbarframe).setBackgroundColor(Color.parseColor(skin));

    if (savedInstanceState == null && f != null) {

        files = new ArrayList<>();
        // adding a cache file to delete where any user interaction elements will be cached
        String fileName = f.getName().substring(0, f.getName().lastIndexOf("."));
        files.add(new BaseFile(getActivity().getExternalCacheDir().getPath() + "/" + fileName));
        if (f.getPath().endsWith(".rar")) {
            openmode = 1;
            SetupRar(null);
        } else {
            openmode = 0;
            SetupZip(null);
        }
    } else {

        f = new File(savedInstanceState.getString(KEY_FILE));
        s = savedInstanceState.getString(KEY_URI);
        uri = Uri.parse(s);
        f = new File(uri.getPath());
        files = savedInstanceState.getParcelableArrayList(KEY_CACHE_FILES);
        isOpen = savedInstanceState.getBoolean(KEY_OPEN);
        if (f.getPath().endsWith(".rar")) {
            openmode = 1;
            SetupRar(savedInstanceState);
        } else {
            openmode = 0;
            SetupZip(savedInstanceState);
        }

    }
    String fileName = null;
    try {
        if (uri.getScheme().equals(KEY_FILE)) {
            fileName = uri.getLastPathSegment();
        } else {
            Cursor cursor = null;
            try {
                cursor = getActivity().getContentResolver().query(uri,
                        new String[] { MediaStore.Images.ImageColumns.DISPLAY_NAME }, null, null, null);

                if (cursor != null && cursor.moveToFirst()) {
                    fileName = cursor
                            .getString(cursor.getColumnIndex(MediaStore.Images.ImageColumns.DISPLAY_NAME));
                }
            } finally {

                if (cursor != null) {
                    cursor.close();
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (fileName == null || fileName.trim().length() == 0)
        fileName = f.getName();
    try {
        mainActivity.setActionBarTitle(fileName);
    } catch (Exception e) {
        mainActivity.setActionBarTitle(getResources().getString(R.string.zip_viewer));
    }
    mainActivity.supportInvalidateOptionsMenu();
    mToolbarHeight = getToolbarHeight(getActivity());
    paddingTop = (mToolbarHeight) + dpToPx(72);
    mToolbarContainer.getViewTreeObserver()
            .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                @Override
                public void onGlobalLayout() {
                    paddingTop = mToolbarContainer.getHeight();
                    mToolbarHeight = mainActivity.toolbar.getHeight();

                    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
                        mToolbarContainer.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                    } else {
                        mToolbarContainer.getViewTreeObserver().removeGlobalOnLayoutListener(this);
                    }
                }

            });

}

From source file:cw.kop.autobackground.sources.SourceInfoFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    Bundle arguments = getArguments();
    sourcePosition = (Integer) arguments.get("position");
    int colorFilterInt = AppSettings.getColorFilterInt(appContext);

    View view = inflater.inflate(R.layout.source_info_fragment, container, false);
    headerView = inflater.inflate(R.layout.source_info_header, null, false);

    settingsContainer = (RelativeLayout) headerView.findViewById(R.id.source_settings_container);

    sourceImage = (ImageView) headerView.findViewById(R.id.source_image);
    sourceTitle = (EditText) headerView.findViewById(R.id.source_title);
    sourcePrefix = (EditText) headerView.findViewById(R.id.source_data_prefix);
    sourceData = (EditText) headerView.findViewById(R.id.source_data);
    sourceSuffix = (EditText) headerView.findViewById(R.id.source_data_suffix);
    sourceNum = (EditText) headerView.findViewById(R.id.source_num);

    ViewGroup.LayoutParams params = sourceImage.getLayoutParams();
    params.height = (int) ((container.getWidth()
            - 2f * getResources().getDimensionPixelSize(R.dimen.side_margin)) / 16f * 9);
    sourceImage.setLayoutParams(params);

    cancelButton = (Button) view.findViewById(R.id.cancel_button);
    saveButton = (Button) view.findViewById(R.id.save_button);

    sourcePrefix.setTextColor(colorFilterInt);
    sourceSuffix.setTextColor(colorFilterInt);
    cancelButton.setTextColor(colorFilterInt);
    saveButton.setTextColor(colorFilterInt);

    // Adjust alpha to get faded hint color from regular text color
    int hintColor = Color.argb(0x88, Color.red(colorFilterInt), Color.green(colorFilterInt),
            Color.blue(colorFilterInt));

    sourceTitle.setHintTextColor(hintColor);
    sourceData.setHintTextColor(hintColor);
    sourceNum.setHintTextColor(hintColor);

    sourceData.setOnClickListener(new View.OnClickListener() {
        @Override/*w w w.  j av  a  2 s. c om*/
        public void onClick(View v) {
            switch (type) {

            case AppSettings.FOLDER:
                selectSource(getPositionOfType(AppSettings.FOLDER));
                break;
            case AppSettings.GOOGLE_ALBUM:
                selectSource(getPositionOfType(AppSettings.GOOGLE_ALBUM));
                break;

            }
            Log.i(TAG, "Data launched folder fragment");
        }
    });

    cancelButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
    saveButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            saveSource();
        }
    });

    sourceSpinnerText = (TextView) headerView.findViewById(R.id.source_spinner_text);
    sourceSpinner = (Spinner) headerView.findViewById(R.id.source_spinner);

    timePref = (CustomSwitchPreference) findPreference("source_time");
    timePref.setChecked(arguments.getBoolean("use_time"));
    timePref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {

            if (!(Boolean) newValue) {
                return true;
            }

            DialogFactory.TimeDialogListener startTimeListener = new DialogFactory.TimeDialogListener() {

                @Override
                public void onTimeSet(TimePicker view, int hour, int minute) {
                    startHour = hour;
                    startMinute = minute;

                    DialogFactory.TimeDialogListener endTimeListener = new DialogFactory.TimeDialogListener() {
                        @Override
                        public void onTimeSet(TimePicker view, int hour, int minute) {
                            endHour = hour;
                            endMinute = minute;

                            timePref.setSummary(String.format("Time active: %02d:%02d - %02d:%02d", startHour,
                                    startMinute, endHour, endMinute));

                        }
                    };

                    DialogFactory.showTimeDialog(appContext, "End time?", endTimeListener, startHour,
                            startMinute);

                }
            };

            DialogFactory.showTimeDialog(appContext, "Start time?", startTimeListener, startHour, startMinute);

            return true;
        }
    });

    if (savedInstanceState != null) {

        if (sourcePosition == -1) {
            sourceSpinner
                    .setSelection(getPositionOfType(savedInstanceState.getString("type", AppSettings.WEBSITE)));
        }

    }

    if (sourcePosition == -1) {
        sourceImage.setVisibility(View.GONE);
        sourceSpinnerText.setVisibility(View.VISIBLE);
        sourceSpinner.setVisibility(View.VISIBLE);

        SourceSpinnerAdapter adapter = new SourceSpinnerAdapter(appContext, R.layout.spinner_row,
                Arrays.asList(getResources().getStringArray(R.array.source_menu)));
        sourceSpinner.setAdapter(adapter);
        sourceSpinner.setSelection(0);
        sourceSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

                selectSource(position);
                Log.i(TAG, "Spinner launched folder fragment");
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });

        type = AppSettings.WEBSITE;
        hint = "URL";
        prefix = "";
        suffix = "";

        startHour = 0;
        startMinute = 0;
        endHour = 0;
        endMinute = 0;
    } else {
        sourceImage.setVisibility(View.VISIBLE);
        sourceSpinnerText.setVisibility(View.GONE);
        sourceSpinner.setVisibility(View.GONE);

        type = arguments.getString("type");

        folderData = arguments.getString("data");
        String data = folderData;

        hint = AppSettings.getSourceDataHint(type);
        prefix = AppSettings.getSourceDataPrefix(type);
        suffix = "";

        switch (type) {
        case AppSettings.GOOGLE_ALBUM:
            sourceTitle.setFocusable(false);
            sourceData.setFocusable(false);
            sourceNum.setFocusable(false);
        case AppSettings.FOLDER:
            data = Arrays.toString(folderData.split(AppSettings.DATA_SPLITTER));
            break;
        case AppSettings.TUMBLR_BLOG:
            suffix = ".tumblr.com";
            break;

        }

        sourceTitle.setText(arguments.getString("title"));
        sourceNum.setText("" + arguments.getInt("num"));
        sourceData.setText(data);

        if (imageDrawable != null) {
            sourceImage.setImageDrawable(imageDrawable);
        }

        boolean showPreview = arguments.getBoolean("preview");
        if (showPreview) {
            sourceImage.setVisibility(View.VISIBLE);
        }

        ((CustomSwitchPreference) findPreference("source_show_preview")).setChecked(showPreview);

        String[] timeArray = arguments.getString("time").split(":|[ -]+");

        try {
            startHour = Integer.parseInt(timeArray[0]);
            startMinute = Integer.parseInt(timeArray[1]);
            endHour = Integer.parseInt(timeArray[2]);
            endMinute = Integer.parseInt(timeArray[3]);
            timePref.setSummary(String.format("Time active: %02d:%02d - %02d:%02d", startHour, startMinute,
                    endHour, endMinute));
        } catch (NumberFormatException e) {
            e.printStackTrace();
            startHour = 0;
            startMinute = 0;
            endHour = 0;
            endMinute = 0;
        }

    }

    setDataWrappers();

    sourceUse = (Switch) headerView.findViewById(R.id.source_use_switch);
    sourceUse.setChecked(arguments.getBoolean("use"));

    if (AppSettings.getTheme().equals(AppSettings.APP_LIGHT_THEME)) {
        view.setBackgroundColor(getResources().getColor(R.color.LIGHT_THEME_BACKGROUND));
    } else {
        view.setBackgroundColor(getResources().getColor(R.color.DARK_THEME_BACKGROUND));
    }

    ListView listView = (ListView) view.findViewById(android.R.id.list);
    listView.addHeaderView(headerView);

    if (savedInstanceState != null) {
        sourceTitle.setText(savedInstanceState.getString("title", ""));
        sourceData.setText(savedInstanceState.getString("data", ""));
        sourceNum.setText(savedInstanceState.getString("num", ""));
    }

    return view;
}

From source file:com.android.mail.compose.ComposeActivity.java

protected void finishSetup(int action, Intent intent, Bundle savedInstanceState) {
    setFocus(action);/*from   ww w. ja  v a 2s .  co m*/
    // Don't bother with the intent if we have procured a message from the
    // intent already.
    if (!hadSavedInstanceStateMessage(savedInstanceState)) {
        initAttachmentsFromIntent(intent);
    }
    initActionBar();
    initFromSpinner(savedInstanceState != null ? savedInstanceState : intent.getExtras(), action);

    // If this is a draft message, the draft account is whatever account was
    // used to open the draft message in Compose.
    if (mDraft != null) {
        mDraftAccount = mReplyFromAccount;
    }

    initChangeListeners();

    // These two should be identical since we check CC and BCC the same way
    boolean showCc = !TextUtils.isEmpty(mCc.getText())
            || (savedInstanceState != null && savedInstanceState.getBoolean(EXTRA_SHOW_CC));
    boolean showBcc = !TextUtils.isEmpty(mBcc.getText())
            || (savedInstanceState != null && savedInstanceState.getBoolean(EXTRA_SHOW_BCC));
    mCcBccView.show(false /* animate */, showCc, showBcc);
    updateHideOrShowCcBcc();
    updateHideOrShowQuotedText(mShowQuotedText);

    mRespondedInline = mInnerSavedState != null && mInnerSavedState.getBoolean(EXTRA_RESPONDED_INLINE);
    if (mRespondedInline) {
        mQuotedTextView.setVisibility(View.GONE);
    }

    mTextChanged = (savedInstanceState != null) ? savedInstanceState.getBoolean(EXTRA_TEXT_CHANGED) : false;
}