Example usage for android.app LoaderManager initLoader

List of usage examples for android.app LoaderManager initLoader

Introduction

In this page you can find the example usage for android.app LoaderManager initLoader.

Prototype

public abstract <D> Loader<D> initLoader(int id, Bundle args, LoaderManager.LoaderCallbacks<D> callback);

Source Link

Document

Ensures a loader is initialized and active.

Usage

From source file:ca.zadrox.dota2esportticker.ui.LiveContentView.java

@Override
public void onResume() {
    super.onResume();

    LoaderManager manager = getLoaderManager();
    manager.initLoader(0, null, this);
    manager.initLoader(1, null, this);
}

From source file:koma.movieapp.ui.MovieDetailActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    //UIUtils.tryTranslateHttpIntent(this);

    boolean shouldBeFloatingWindow = shouldBeFloatingWindow();
    if (shouldBeFloatingWindow) {
        setupFloatingWindow();//from   ww w .jav a 2  s .  com
    }

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

    final Toolbar toolbar = getActionBarToolbar();
    toolbar.setNavigationIcon(shouldBeFloatingWindow ? R.drawable.ic_ab_close : R.drawable.ic_up);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            finishAfterTransition();
        }
    });
    mHandler.post(new Runnable() {
        @Override
        public void run() {
            toolbar.setTitle("");
        }
    });

    if (savedInstanceState == null) {
        Uri sessionUri = getIntent().getData();
    }

    mArguments = getIntent().getExtras();

    //
    //        if (extras == null) {
    //            return;
    //        }
    //
    //        mMovieId = Integer.parseInt(extras.getString("movieId"));

    mFABElevation = getResources().getDimensionPixelSize(R.dimen.fab_elevation);
    mMaxHeaderElevation = getResources().getDimensionPixelSize(R.dimen.session_detail_max_header_elevation);

    mTagColorDotSize = getResources().getDimensionPixelSize(R.dimen.tag_color_dot_size);

    mHandler = new Handler();

    if (mBackdropImageLoader == null) {
        mBackdropImageLoader = new ImageLoader(this, R.drawable.person_image_empty);
    }
    if (mNoPlaceholderImageLoader == null) {
        mNoPlaceholderImageLoader = new ImageLoader(this);
    }

    mScrollView = (ObservableScrollView) findViewById(R.id.scroll_view);
    mScrollView.addCallbacks(this);
    ViewTreeObserver vto = mScrollView.getViewTreeObserver();
    if (vto.isAlive()) {
        vto.addOnGlobalLayoutListener(mGlobalLayoutListener);
    }

    mScrollViewChild = findViewById(R.id.scroll_view_child);
    mScrollViewChild.setVisibility(View.INVISIBLE);

    mDetailsContainer = findViewById(R.id.details_container);
    mHeaderBox = findViewById(R.id.header_movie);
    mTitle = (TextView) findViewById(R.id.movie_title);
    mMovieRating = (TextView) findViewById(R.id.movie_rating);
    mMovieRuntime = (TextView) findViewById(R.id.movie_runtime);
    mPhotoViewContainer = findViewById(R.id.movie_photo_container);
    mPhotoView = (ImageView) findViewById(R.id.movie_backdrop);

    mMovieOverview = (TextView) findViewById(R.id.movie_overview);
    mMovieDirectors = (LinearLayout) findViewById(R.id.movie_directors_container);
    //mMovieWriters = (LinearLayout) findViewById(R.id.movie_writers_container);
    //mMovieProducers = (LinearLayout) findViewById(R.id.movie_producers_container);
    mMovieCast = (LinearLayout) findViewById(R.id.movie_cast_container);
    mMovieGenres = (LinearLayout) findViewById(R.id.movie_genre);
    mMovieGenresContainer = (ViewGroup) findViewById(R.id.movie_genres_container);

    mAddScheduleButton = (CheckableFrameLayout) findViewById(R.id.add_schedule_button);

    //ViewCompat.setTransitionName(mPhotoView, TRANSITION_NAME_PHOTO);

    LoaderManager manager = getLoaderManager();
    manager.initLoader(0, mArguments, this);
}

From source file:com.google.samples.apps.iosched.map.MapFragment.java

@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;//from   w w w .  ja v  a 2s .  c o  m
    mMap.setIndoorEnabled(true);
    mMap.setMyLocationEnabled(false);
    mMap.setOnMarkerClickListener(this);
    mMap.setOnIndoorStateChangeListener(this);
    mMap.setOnMapClickListener(this);

    mMap.setOnCameraIdleListener(new GoogleMap.OnCameraIdleListener() {
        @Override
        public void onCameraIdle() {
            if (mMap.getCameraPosition().zoom <= DETAILED_MAP_ZOOM_THRESHOLD) {
                showMarkersForAllFloors(false);
                mOsloSpektrumMarker.setVisible(true);
            } else {
                setFloorElementsVisible(mFloor, true);
                mOsloSpektrumMarker.setVisible(false);
            }
        }
    });

    UiSettings mapUiSettings = mMap.getUiSettings();
    mapUiSettings.setZoomControlsEnabled(false);
    mapUiSettings.setMapToolbarEnabled(false);

    // load all markers
    LoaderManager lm = getLoaderManager();
    lm.initLoader(TOKEN_LOADER_MARKERS, null, mMarkerLoader).forceLoad();

    setupMap(true);
}

From source file:ca.zadrox.dota2esportticker.ui.MatchDetailActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_matches_detail);

    final Toolbar toolbar = getActionBarToolbar();
    toolbar.setNavigationIcon(R.drawable.ic_up);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override//from  ww w.  ja v a  2s . c  o m
        public void onClick(View v) {
            onBackPressed();
        }
    });

    mHandler.post(new Runnable() {
        @Override
        public void run() {
            toolbar.setTitle("");
        }
    });

    //setmUrl();

    mFABElevation = getResources().getDimensionPixelSize(R.dimen.fab_elevation);
    mMaxHeaderElevation = getResources().getDimensionPixelSize(R.dimen.session_detail_max_header_elevation);

    mScrollView = (ObservableScrollView) findViewById(R.id.scroll_view);
    mScrollView.addCallbacks(this);
    ViewTreeObserver vto = mScrollView.getViewTreeObserver();
    if (vto.isAlive()) {
        vto.addOnGlobalLayoutListener(mGlobalLayoutListener);
    }

    mScrollViewChild = findViewById(R.id.scroll_view_child);
    // mScrollViewChild.setVisibility(View.INVISIBLE);

    mDetailsContainer = (ViewGroup) findViewById(R.id.details_container);
    mDetailsContainer.setY(2000);
    mHeaderBox = findViewById(R.id.header_match);
    mTitle = (TextView) findViewById(R.id.header_title);
    mSubtitle = (TextView) findViewById(R.id.header_subtitle);
    mMatchViewContainer = findViewById(R.id.match_photo_container);
    //mMatchViewContainer.setVisibility(View.INVISIBLE);
    mMatchTeamOneImageView = (ImageView) findViewById(R.id.match_team_one_photo);
    mMatchTeamTwoImageView = (ImageView) findViewById(R.id.match_team_two_photo);
    mMatchImageView = (ImageView) findViewById(R.id.match_photo);
    mMatchScoreView = (TextView) findViewById(R.id.match_score_view);
    mBestOfView = (TextView) findViewById(R.id.match_bo);

    mAddReminderButton = (CheckableFrameLayout) findViewById(R.id.add_schedule_button);
    mAddReminderButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            boolean starred = !mStarred;
            showStarred(starred, true);
            setSessionStarred(starred);
        }
    });

    mGGnetMatchId = getIntent().getLongExtra(ARGS_GG_MATCH_ID, 0);

    mMatchImageView.setColorFilter(Color.rgb(123, 123, 123), android.graphics.PorterDuff.Mode.MULTIPLY);

    DisplayMetrics displayMetrics = getResources().getDisplayMetrics();

    final int dWidth = displayMetrics.widthPixels * 2 / 3;

    Picasso.with(this).load(R.drawable.drawable_dota_bg_dire_ancient).config(Bitmap.Config.ARGB_8888)
            .resize(Math.round(dWidth * PHOTO_ASPECT_RATIO), dWidth)
            .transform(new CropImageTransform(displayMetrics.heightPixels, displayMetrics.widthPixels))
            .into(mMatchImageView);

    LoaderManager manager = getLoaderManager();
    mHasPhoto = true;

    manager.initLoader(DB_LOADER, null, mCursorCallbacks);
}

From source file:com.example.android.recyclingbanks.MainActivity.java

protected void getDataLoaderGoing() {
    Log.i("getDataLoaderGoing", "Loader manager next???");
    ConnectivityManager cm = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE);

    NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
    boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting();
    if (isConnected) {
        LoaderManager loaderManager = getLoaderManager();
        loaderManager.initLoader(0, null, this);
    } else {/*from  w ww  .j  a  va 2  s. c om*/
        mProgressBar.setVisibility(View.GONE);
        mSpinnerLayout.setVisibility(View.GONE);
        mEmptyView.setText("No internet connection");
    }
}

From source file:com.google.samples.apps.iosched.ui.SessionDetailActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    UIUtils.tryTranslateHttpIntent(this);
    BeamUtils.tryUpdateIntentFromBeam(this);
    boolean shouldBeFloatingWindow = shouldBeFloatingWindow();
    if (shouldBeFloatingWindow) {
        setupFloatingWindow();//from ww w .  java 2 s .com
    }

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

    final Toolbar toolbar = getActionBarToolbar();
    toolbar.setNavigationIcon(shouldBeFloatingWindow ? R.drawable.ic_ab_close : R.drawable.ic_up);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            finish();
        }
    });
    mHandler.post(new Runnable() {
        @Override
        public void run() {
            toolbar.setTitle("");
        }
    });

    if (savedInstanceState == null) {
        Uri sessionUri = getIntent().getData();
        BeamUtils.setBeamSessionUri(this, sessionUri);
    }

    mSessionUri = getIntent().getData();

    if (mSessionUri == null) {
        return;
    }

    mSessionId = ScheduleContract.Sessions.getSessionId(mSessionUri);

    mFABElevation = getResources().getDimensionPixelSize(R.dimen.fab_elevation);
    mMaxHeaderElevation = getResources().getDimensionPixelSize(R.dimen.session_detail_max_header_elevation);

    mTagColorDotSize = getResources().getDimensionPixelSize(R.dimen.tag_color_dot_size);

    mHandler = new Handler();

    if (mSpeakersImageLoader == null) {
        mSpeakersImageLoader = new ImageLoader(this, R.drawable.person_image_empty);
    }
    if (mNoPlaceholderImageLoader == null) {
        mNoPlaceholderImageLoader = new ImageLoader(this);
    }

    mScrollView = (ObservableScrollView) findViewById(R.id.scroll_view);
    mScrollView.addCallbacks(this);
    ViewTreeObserver vto = mScrollView.getViewTreeObserver();
    if (vto.isAlive()) {
        vto.addOnGlobalLayoutListener(mGlobalLayoutListener);
    }

    mScrollViewChild = findViewById(R.id.scroll_view_child);
    mScrollViewChild.setVisibility(View.INVISIBLE);

    mDetailsContainer = findViewById(R.id.details_container);
    mHeaderBox = findViewById(R.id.header_session);
    mTitle = (TextView) findViewById(R.id.session_title);
    mSubtitle = (TextView) findViewById(R.id.session_subtitle);
    mPhotoViewContainer = findViewById(R.id.session_photo_container);
    mPhotoView = (ImageView) findViewById(R.id.session_photo);

    mPlusOneButton = (PlusOneButton) findViewById(R.id.plus_one_button);
    mAbstract = (TextView) findViewById(R.id.session_abstract);
    mRequirements = (TextView) findViewById(R.id.session_requirements);
    mTags = (LinearLayout) findViewById(R.id.session_tags);
    mTagsContainer = (ViewGroup) findViewById(R.id.session_tags_container);

    mAddScheduleButton = (CheckableFrameLayout) findViewById(R.id.add_schedule_button);
    mAddScheduleButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            boolean starred = !mStarred;
            SessionsHelper helper = new SessionsHelper(SessionDetailActivity.this);
            showStarred(starred, true);
            helper.setSessionStarred(mSessionUri, starred, mTitleString);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                mAddScheduleButton.announceForAccessibility(
                        starred ? getString(R.string.session_details_a11y_session_added)
                                : getString(R.string.session_details_a11y_session_removed));
            }

            /* [ANALYTICS:EVENT]
             * TRIGGER:   Add or remove a session from My Schedule.
             * CATEGORY:  'Session'
             * ACTION:    'Starred' or 'Unstarred'
             * LABEL:     Session title/subtitle.
             * [/ANALYTICS]
             */
            AnalyticsManager.sendEvent("Session", starred ? "Starred" : "Unstarred", mTitleString, 0L);
        }
    });

    ViewCompat.setTransitionName(mPhotoView, TRANSITION_NAME_PHOTO);

    LoaderManager manager = getLoaderManager();
    manager.initLoader(SessionsQuery._TOKEN, null, this);
    manager.initLoader(SpeakersQuery._TOKEN, null, this);
    manager.initLoader(TAG_METADATA_TOKEN, null, this);
}

From source file:com.ncode.android.apps.schedo.ui.EventDetailActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    UIUtils.tryTranslateHttpIntent(this);
    BeamUtils.tryUpdateIntentFromBeam(this);
    boolean shouldBeFloatingWindow = shouldBeFloatingWindow();
    if (shouldBeFloatingWindow) {
        setupFloatingWindow();//from   w w  w  .ja v  a  2 s.c  o m
    }

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

    final Toolbar toolbar = getActionBarToolbar();
    toolbar.setNavigationIcon(shouldBeFloatingWindow ? R.drawable.ic_ab_close : R.drawable.ic_up);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            finish();
        }
    });
    mHandler.post(new Runnable() {
        @Override
        public void run() {
            toolbar.setTitle("");
        }
    });

    if (savedInstanceState == null) {
        Uri sessionUri = getIntent().getData();
        BeamUtils.setBeamSessionUri(this, sessionUri);
    }

    mSessionUri = getIntent().getData();

    if (mSessionUri == null) {
        return;
    }

    mSessionId = ScheduleContract.Sessions.getSessionId(mSessionUri);

    mFABElevation = getResources().getDimensionPixelSize(R.dimen.fab_elevation);
    mMaxHeaderElevation = getResources().getDimensionPixelSize(R.dimen.session_detail_max_header_elevation);

    mTagColorDotSize = getResources().getDimensionPixelSize(R.dimen.tag_color_dot_size);

    mHandler = new Handler();

    if (mSpeakersImageLoader == null) {
        mSpeakersImageLoader = new ImageLoader(this, R.drawable.person_image_empty);
    }
    if (mNoPlaceholderImageLoader == null) {
        mNoPlaceholderImageLoader = new ImageLoader(this);
    }

    mScrollView = (ObservableScrollView) findViewById(R.id.scroll_view);
    mScrollView.addCallbacks(this);
    ViewTreeObserver vto = mScrollView.getViewTreeObserver();
    if (vto.isAlive()) {
        vto.addOnGlobalLayoutListener(mGlobalLayoutListener);
    }

    mScrollViewChild = findViewById(R.id.scroll_view_child);
    mScrollViewChild.setVisibility(View.INVISIBLE);

    mDetailsContainer = findViewById(R.id.details_container);
    mHeaderBox = findViewById(R.id.header_session);
    mTitle = (TextView) findViewById(R.id.session_title);
    mSubtitle = (TextView) findViewById(R.id.session_subtitle);
    mPhotoViewContainer = findViewById(R.id.session_photo_container);
    mPhotoView = (ImageView) findViewById(R.id.session_photo);

    mPlusOneButton = (PlusOneButton) findViewById(R.id.plus_one_button);
    mAbstract = (TextView) findViewById(R.id.session_abstract);
    mRequirements = (TextView) findViewById(R.id.session_requirements);
    mTags = (LinearLayout) findViewById(R.id.session_tags);
    mTagsContainer = (ViewGroup) findViewById(R.id.session_tags_container);

    mAddScheduleButton = (CheckableFrameLayout) findViewById(R.id.add_schedule_button);
    mAddScheduleButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            boolean starred = !mStarred;
            SessionsHelper helper = new SessionsHelper(EventDetailActivity.this);
            showStarred(starred, true);
            helper.setSessionStarred(mSessionUri, starred, mTitleString);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                mAddScheduleButton.announceForAccessibility(
                        starred ? getString(R.string.session_details_a11y_session_added)
                                : getString(R.string.session_details_a11y_session_removed));
            }

            /* [ANALYTICS:EVENT]
             * TRIGGER:   Add or remove a session from My Schedule.
             * CATEGORY:  'Session'
             * ACTION:    'Starred' or 'Unstarred'
             * LABEL:     Session title/subtitle.
             * [/ANALYTICS]
             */
            AnalyticsManager.sendEvent("Session", starred ? "Starred" : "Unstarred", mTitleString, 0L);
        }
    });

    ViewCompat.setTransitionName(mPhotoView, TRANSITION_NAME_PHOTO);

    LoaderManager manager = getLoaderManager();
    manager.initLoader(SessionsQuery._TOKEN, null, this);
    manager.initLoader(SpeakersQuery._TOKEN, null, this);
    manager.initLoader(TAG_METADATA_TOKEN, null, this);
}

From source file:com.google.samples.apps.iosched.ui.CurrentSessionActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    UIUtils.tryTranslateHttpIntent(this);
    BeamUtils.tryUpdateIntentFromBeam(this);
    boolean shouldBeFloatingWindow = false;
    if (shouldBeFloatingWindow) {
        setupFloatingWindow();/*  www  .  j  a  v a 2 s.com*/
    }
    super.onCreate(savedInstanceState);
    mSessionId = getCurrentSessionId();
    if (mSessionId == null) {
        complainMissingCurrentTalkId();
    } else {
        setContentView(R.layout.activity_current_session);

        final Toolbar toolbar = getActionBarToolbar();
        toolbar.setNavigationIcon(shouldBeFloatingWindow ? R.drawable.ic_ab_close : R.drawable.ic_up);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        mHandler.post(new Runnable() {
            @Override
            public void run() {
                toolbar.setTitle("");
            }
        });

        mSessionUri = ScheduleContract.Sessions.buildSessionUri(mSessionId);

        mFABElevation = getResources().getDimensionPixelSize(R.dimen.fab_elevation);
        mMaxHeaderElevation = getResources().getDimensionPixelSize(R.dimen.session_detail_max_header_elevation);

        mTagColorDotSize = getResources().getDimensionPixelSize(R.dimen.tag_color_dot_size);

        mHandler = new Handler();

        if (mSpeakersImageLoader == null) {
            mSpeakersImageLoader = new ImageLoader(this, R.drawable.person_image_empty);
        }
        if (mNoPlaceholderImageLoader == null) {
            mNoPlaceholderImageLoader = new ImageLoader(this);
        }

        mScrollView = (ObservableScrollView) findViewById(R.id.scroll_view);
        mScrollView.addCallbacks(this);
        ViewTreeObserver vto = mScrollView.getViewTreeObserver();
        if (vto.isAlive()) {
            vto.addOnGlobalLayoutListener(mGlobalLayoutListener);
        }

        mScrollViewChild = findViewById(R.id.scroll_view_child);
        mScrollViewChild.setVisibility(View.INVISIBLE);

        mDetailsContainer = findViewById(R.id.details_container);
        mHeaderBox = findViewById(R.id.header_session);
        mTitle = (TextView) findViewById(R.id.session_title);
        mSubtitle = (TextView) findViewById(R.id.session_subtitle);
        mPhotoViewContainer = findViewById(R.id.session_photo_container);
        mPhotoView = (ImageView) findViewById(R.id.session_photo);

        mPlusOneButton = (PlusOneButton) findViewById(R.id.plus_one_button);
        mAbstract = (TextView) findViewById(R.id.session_abstract);
        mRequirements = (TextView) findViewById(R.id.session_requirements);
        mTags = (LinearLayout) findViewById(R.id.session_tags);
        mTagsContainer = (ViewGroup) findViewById(R.id.session_tags_container);

        mAddScheduleButton = (CheckableFrameLayout) findViewById(R.id.add_schedule_button);
        mAddScheduleButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                boolean starred = !mStarred;
                SessionsHelper helper = new SessionsHelper(CurrentSessionActivity.this);
                showStarred(starred, true);
                helper.setSessionStarred(mSessionUri, starred, mTitleString);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                    mAddScheduleButton.announceForAccessibility(
                            starred ? getString(R.string.session_details_a11y_session_added)
                                    : getString(R.string.session_details_a11y_session_removed));
                }

                /* [ANALYTICS:EVENT]
                 * TRIGGER:   Add or remove a session from My Schedule.
                 * CATEGORY:  'Session'
                 * ACTION:    'Starred' or 'Unstarred'
                 * LABEL:     Session title/subtitle.
                 * [/ANALYTICS]
                 */
                AnalyticsManager.sendEvent("Session", starred ? "Starred" : "Unstarred", mTitleString, 0L);
            }
        });

        ViewCompat.setTransitionName(mPhotoView, TRANSITION_NAME_PHOTO);

        LoaderManager manager = getLoaderManager();
        manager.initLoader(SessionsQuery._TOKEN, null, this);
        manager.initLoader(SpeakersQuery._TOKEN, null, this);
        manager.initLoader(TAG_METADATA_TOKEN, null, this);
    }
}

From source file:com.saarang.samples.apps.iosched.ui.SessionDetailActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    UIUtils.tryTranslateHttpIntent(this);
    BeamUtils.tryUpdateIntentFromBeam(this);
    boolean shouldBeFloatingWindow = shouldBeFloatingWindow();
    if (shouldBeFloatingWindow) {
        setupFloatingWindow();/*  w ww .j ava  2 s.co m*/
    }

    super.onCreate(savedInstanceState);
    setContentView(com.saarang.samples.apps.iosched.R.layout.activity_session_detail);

    final Toolbar toolbar = getActionBarToolbar();
    toolbar.setNavigationIcon(shouldBeFloatingWindow ? com.saarang.samples.apps.iosched.R.drawable.ic_ab_close
            : com.saarang.samples.apps.iosched.R.drawable.ic_up);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            finish();
        }
    });
    mHandler.post(new Runnable() {
        @Override
        public void run() {
            toolbar.setTitle("");
        }
    });

    if (savedInstanceState == null) {
        Uri sessionUri = getIntent().getData();
        BeamUtils.setBeamSessionUri(this, sessionUri);
    }

    mSessionUri = getIntent().getData();

    if (mSessionUri == null) {
        return;
    }

    mSessionId = ScheduleContract.Sessions.getSessionId(mSessionUri);

    mFABElevation = getResources()
            .getDimensionPixelSize(com.saarang.samples.apps.iosched.R.dimen.fab_elevation);
    mMaxHeaderElevation = getResources().getDimensionPixelSize(
            com.saarang.samples.apps.iosched.R.dimen.session_detail_max_header_elevation);

    mTagColorDotSize = getResources()
            .getDimensionPixelSize(com.saarang.samples.apps.iosched.R.dimen.tag_color_dot_size);

    mHandler = new Handler();

    if (mSpeakersImageLoader == null) {
        mSpeakersImageLoader = new ImageLoader(this,
                com.saarang.samples.apps.iosched.R.drawable.person_image_empty);
    }
    if (mNoPlaceholderImageLoader == null) {
        mNoPlaceholderImageLoader = new ImageLoader(this);
    }

    mScrollView = (ObservableScrollView) findViewById(com.saarang.samples.apps.iosched.R.id.scroll_view);
    mScrollView.addCallbacks(this);
    ViewTreeObserver vto = mScrollView.getViewTreeObserver();
    if (vto.isAlive()) {
        vto.addOnGlobalLayoutListener(mGlobalLayoutListener);
    }

    mScrollViewChild = findViewById(com.saarang.samples.apps.iosched.R.id.scroll_view_child);
    mScrollViewChild.setVisibility(View.INVISIBLE);

    mDetailsContainer = findViewById(com.saarang.samples.apps.iosched.R.id.details_container);
    mHeaderBox = findViewById(com.saarang.samples.apps.iosched.R.id.header_session);
    mTitle = (TextView) findViewById(com.saarang.samples.apps.iosched.R.id.session_title);
    mSubtitle = (TextView) findViewById(com.saarang.samples.apps.iosched.R.id.session_subtitle);
    mPhotoViewContainer = findViewById(com.saarang.samples.apps.iosched.R.id.session_photo_container);
    mPhotoView = (ImageView) findViewById(com.saarang.samples.apps.iosched.R.id.session_photo);

    mPlusOneButton = (PlusOneButton) findViewById(com.saarang.samples.apps.iosched.R.id.plus_one_button);
    mAbstract = (TextView) findViewById(com.saarang.samples.apps.iosched.R.id.session_abstract);
    mRequirements = (TextView) findViewById(com.saarang.samples.apps.iosched.R.id.session_requirements);
    mTags = (LinearLayout) findViewById(com.saarang.samples.apps.iosched.R.id.session_tags);
    mTagsContainer = (ViewGroup) findViewById(com.saarang.samples.apps.iosched.R.id.session_tags_container);

    mAddScheduleButton = (CheckableFrameLayout) findViewById(
            com.saarang.samples.apps.iosched.R.id.add_schedule_button);
    mAddScheduleButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            boolean starred = !mStarred;
            SessionsHelper helper = new SessionsHelper(SessionDetailActivity.this);
            showStarred(starred, true);
            helper.setSessionStarred(mSessionUri, starred, mTitleString);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                mAddScheduleButton.announceForAccessibility(starred
                        ? getString(
                                com.saarang.samples.apps.iosched.R.string.session_details_a11y_session_added)
                        : getString(
                                com.saarang.samples.apps.iosched.R.string.session_details_a11y_session_removed));
            }

            /* [ANALYTICS:EVENT]
             * TRIGGER:   Add or remove a session from My Schedule.
             * CATEGORY:  'Session'
             * ACTION:    'Starred' or 'Unstarred'
             * LABEL:     Session title/subtitle.
             * [/ANALYTICS]
             */
            AnalyticsManager.sendEvent("Session", starred ? "Starred" : "Unstarred", mTitleString, 0L);
        }
    });

    ViewCompat.setTransitionName(mPhotoView, TRANSITION_NAME_PHOTO);

    LoaderManager manager = getLoaderManager();
    manager.initLoader(SessionsQuery._TOKEN, null, this);
    manager.initLoader(SpeakersQuery._TOKEN, null, this);
    manager.initLoader(TAG_METADATA_TOKEN, null, this);
}

From source file:com.tct.mail.ui.ConversationViewFragment.java

@Override
public int loadSingleMessageBackground(Message msg) {
    Context context = getContext();
    com.tct.emailcommon.provider.Account account = com.tct.emailcommon.provider.Account
            .getAccountForMessageId(context, msg.getId());
    int status = -1;
    if (account == null) {
        return 0;
    }//  w w w .java 2  s .c o m
    /* String protocol = account.getProtocol(getContext());
    if (protocol.equals(HostAuth.SCHEME_IMAP)) {
    status = ImapService.loadUnsyncedMessage(getContext(), msg.getId());
    } else if (protocol.equals(HostAuth.SCHEME_POP3)){
    status = Pop3Service.loadUnsyncedMessage(getContext(),msg.getId()); */
    if (mAdapter != null && mAdapter.getMessageHeaderItem() != null) {
        mMessageHeaderView = mAdapter.getMessageHeaderView();
    }
    if (mMessageHeaderView != null) {
        mMessageHeaderView.showRemainProgress(true);
    }
    mIsDownloadingRemaining = true;
    LoaderManager lm = getLoaderManager();
    Bundle bundle = new Bundle();
    bundle.putParcelable(EXTRA_MESSAGE, msg);
    lm.initLoader(LOADER_DOWNLOAD_REMAINING, bundle, mDownloadRemainCallback);
    return status;
}