Example usage for android.app FragmentManager findFragmentByTag

List of usage examples for android.app FragmentManager findFragmentByTag

Introduction

In this page you can find the example usage for android.app FragmentManager findFragmentByTag.

Prototype

public abstract Fragment findFragmentByTag(String tag);

Source Link

Document

Finds a fragment that was identified by the given tag either when inflated from XML or as supplied when added in a transaction.

Usage

From source file:com.hit.jj.mapshow.RoutingActivity.java

@Override
public void onDialogRouteClicked(Point p1, Point p2) {
    FragmentManager fm = getFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    ft.remove(fm.findFragmentByTag("Dialog")).commit();

    pathfind(p1, p2);/*from w  ww  .  j  a  v  a  2 s  .c o  m*/

}

From source file:com.hit.jj.mapshow.RoutingActivity.java

@Override
public void onDialogRouteClicked(Point p) {
    //        Point s1 = new Point(26.0734997,119.3150024);
    Point s1 = new Point(26.1023006, 119.2789993);
    Point s2 = new Point(mLocation.getY(), mLocation.getX());
    FragmentManager fm = getFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    ft.remove(fm.findFragmentByTag("SpeakDialog")).commit();
    pathfind(s2, p);//
    //pathfind(s1, p);//
}

From source file:com.hit.jj.mapshow.RoutingActivity.java

@Override
public void onSegmentSelected(String id) {

    if (id == null)
        return;// w  ww.j a  v a  2 s .  c  o  m
    FragmentManager fm = getFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    ft.remove(fm.findFragmentByTag("Nav Drawer")).commit();
    clearAll();
    // Look for the graphic that corresponds to this direction
    removeRoad(mPaths, id);
    new Handler().post(new Runnable() {
        @Override
        public void run() {
            updateUI();
        }
    });
}

From source file:uk.org.downiesoft.slideshow.SlideShowActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Window win = getWindow();// www.  j a  va  2 s. c o m
    win.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
            WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    win.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION,
            WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
    win.requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    mUiHider = new UiHider(this);
    getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(mUiHider);
    mCacheManager = ThumbnailCacheManager.getInstance(this);
    SlideShowActivity.debug(1, TAG, "onCreate: %s",
            savedInstanceState == null ? "null" : savedInstanceState.toString());
    setContentView(R.layout.activity_slide_show);
    PreferenceManager.setDefaultValues(this, R.xml.view_preferences, false);
    PreferenceManager.setDefaultValues(this, R.xml.slideshow_preferences, false);
    PreferenceManager.setDefaultValues(this, R.xml.cache_preferences, false);
    PreferenceManager.setDefaultValues(this, R.xml.wallpaper_preferences, false);
    PreferenceManager.setDefaultValues(this, R.xml.other_preferences, false);
    mSlideshowSettings = PreferenceManager.getDefaultSharedPreferences(this);
    int thumbSize = Integer.parseInt(mSlideshowSettings.getString(getString(R.string.PREFS_THUMBSIZE), "1"));
    // Hack to convert old hard-coded thumbsize settings to platform dependent sizes
    if (thumbSize > 2) {
        thumbSize = thumbSize / 90;
        SharedPreferences.Editor editor = mSlideshowSettings.edit();
        editor.putString(getString(R.string.PREFS_THUMBSIZE), Integer.toString(thumbSize));
        editor.apply();
    }
    FragmentManager fm = getFragmentManager();
    int cacheLimit = Integer
            .parseInt(mSlideshowSettings.getString(getString(R.string.PREFS_CACHE_LIMIT), "10"));
    mPreviewButton = (ImageView) findViewById(R.id.slideShowImageButton);
    mPreviewView = (FrameLayout) findViewById(R.id.previewContainer);
    RelativeLayout divider = (RelativeLayout) findViewById(R.id.frameDivider);
    if (divider != null) {
        divider.setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent event) {
                return mGestureDetector.onTouchEvent(event) || view.onTouchEvent(event);
            }
        });
    }
    mPreviewFragment = (PreviewFragment) fm.findFragmentByTag(PreviewFragment.TAG);
    if (mPreviewView != null && mPreviewFragment == null) {
        mPreviewFragment = new PreviewFragment();
        fm.beginTransaction().replace(R.id.previewContainer, mPreviewFragment, PreviewFragment.TAG).commit();
    }
    mGridViewFragment = (GridViewFragment) fm.findFragmentByTag(GridViewFragment.TAG);
    if (mGridViewFragment == null) {
        mGridViewFragment = new GridViewFragment();
        FragmentTransaction ft = fm.beginTransaction();
        ft.replace(R.id.fragmentContainer, mGridViewFragment, GridViewFragment.TAG);
        ft.commit();
    }
    mGestureDetector = new GestureDetector(this, new DividerGestureListener());
    // restart/stop service as required
    Intent intent = getIntent();
    if (intent != null && intent.getAction() != null && intent.getAction().equals(ACTION_STOP_WALLPAPER)
            && isServiceRunning()) {
        stopWallpaperService();
        finish();
    } else {
        if (!mSlideshowSettings.getBoolean(getString(R.string.PREFS_WALLPAPER_ENABLE), false)) {
            if (isServiceRunning()) {
                stopWallpaperService();
            }
        } else {
            if (!isServiceRunning()) {
                Intent startIntent = new Intent(SlideShowActivity.this, WallpaperService.class);
                startService(startIntent);
                invalidateOptionsMenu();
            }
        }
    }
    mCacheManager.tidyCache(cacheLimit);
    BitmapManager.setDisplayMetrics(getResources().getDisplayMetrics());
}

From source file:com.geecko.QuickLyric.MainActivity.java

private void selectItem(int position) {
    FragmentManager fragmentManager = getFragmentManager();
    Fragment newFragment;//from w ww . j  ava  2 s.c o  m
    String tag;
    switch (position) {
    default:
        // Lyrics
        tag = LYRICS_FRAGMENT_TAG;
        newFragment = fragmentManager.findFragmentByTag(tag);
        if (newFragment == null || !(newFragment instanceof LyricsViewFragment))
            newFragment = new LyricsViewFragment();
        ((LyricsViewFragment) newFragment).showTransitionAnim = true;
        break;
    case 1:
        // Saved Lyrics
        tag = LOCAL_LYRICS_FRAGMENT_TAG;
        newFragment = fragmentManager.findFragmentByTag(tag);
        if (newFragment == null || !(newFragment instanceof LocalLyricsFragment))
            newFragment = new LocalLyricsFragment();
        ((LocalLyricsFragment) newFragment).showTransitionAnim = true;
        break;
    case 2:
        // Separator
        return;
    case 3:
        // Settings
        if (drawer instanceof DrawerLayout)
            ((DrawerLayout) drawer).closeDrawer(drawerView);
        drawer.postDelayed(new Runnable() {
            @Override
            public void run() {
                Intent settingsIntent = new Intent(MainActivity.this, SettingsActivity.class);
                startActivityForResult(settingsIntent, 77);
            }
        }, 250);
        return;
    case 4:
        // Feedback
        return;
    case 5:
        // About Dialog
        if (drawer instanceof DrawerLayout)
            ((DrawerLayout) drawer).closeDrawer(drawerView);
        drawer.postDelayed(new Runnable() {
            @Override
            public void run() {
                Intent aboutIntent = new Intent(MainActivity.this, AboutActivity.class);
                startActivityForResult(aboutIntent, 77);
            }
        }, 250);
        return;
    }

    final Fragment activeFragment = getDisplayedFragment(getActiveFragments());
    prepareAnimations(activeFragment);

    // Insert the fragment by replacing any existing fragment
    if (newFragment != activeFragment) {
        if (mActionMode != null)
            mActionMode.finish();
        FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
        fragmentTransaction.setCustomAnimations(R.animator.slide_in_start, R.animator.slide_out_start,
                R.animator.slide_in_start, R.animator.slide_out_start);
        fragmentTransaction.hide(activeFragment);
        if (newFragment.isAdded())
            fragmentTransaction.show(newFragment);
        else
            fragmentTransaction.add(id.main_fragment_container, newFragment, tag);
        ((CollapsingToolbarLayout) findViewById(R.id.toolbar_layout)).setCollapsedTitleTextColor(Color.WHITE);
        fragmentTransaction.commit();

        if (activeFragment instanceof LyricsViewFragment || newFragment instanceof LyricsViewFragment) {
            final Fragment newFragmentCopy = newFragment;
            activeFragment.getView().postDelayed(new Runnable() {
                @Override
                public void run() {
                    if (activeFragment instanceof LyricsViewFragment) {
                        expandToolbar(false);
                        showRefreshFab(false);
                    } else if (newFragmentCopy instanceof LyricsViewFragment) {
                        expandToolbar(true);
                        showRefreshFab(true);
                    }
                }
            }, getResources().getInteger(android.R.integer.config_longAnimTime));
        }
    }
    if (drawer instanceof DrawerLayout && (newFragment == activeFragment))
        ((DrawerLayout) drawer).closeDrawer(drawerView);
}

From source file:com.lgallardo.qbittorrentclient.TorrentDetailsFragment.java

public void updateDetails(Torrent torrent) {

    //        Log.d("Debug", "Updating details");

    try {//from  ww  w . ja  va 2s .c  o m

        // Hide herderInfo in phone's view
        if (getActivity().findViewById(R.id.one_frame) != null) {
            MainActivity.headerInfo.setVisibility(View.GONE);
        }

        // Get values from current activity
        name = torrent.getFile();
        size = torrent.getSize();
        hash = torrent.getHash();
        ratio = torrent.getRatio();
        state = torrent.getState();
        leechs = torrent.getLeechs();
        seeds = torrent.getSeeds();
        progress = torrent.getProgress();
        priority = torrent.getPriority();
        eta = torrent.getEta();
        uploadSpeed = torrent.getUploadSpeed();
        downloadSpeed = torrent.getDownloadSpeed();
        downloaded = torrent.getDownloaded();
        addedOn = torrent.getAddedOn();
        completionOn = torrent.getCompletionOn();
        label = torrent.getLabel();

        int index = torrent.getProgress().indexOf(".");

        if (index == -1) {
            index = torrent.getProgress().indexOf(",");

            if (index == -1) {
                index = torrent.getProgress().length();
            }
        }

        percentage = torrent.getProgress().substring(0, index);

        FragmentManager fragmentManager = getFragmentManager();

        TorrentDetailsFragment detailsFragment = null;

        if (getActivity().findViewById(R.id.one_frame) != null) {
            detailsFragment = (TorrentDetailsFragment) fragmentManager.findFragmentByTag("firstFragment");
        } else {
            detailsFragment = (TorrentDetailsFragment) fragmentManager.findFragmentByTag("secondFragment");
        }

        View rootView = detailsFragment.getView();

        TextView nameTextView = (TextView) rootView.findViewById(R.id.torrentName);
        TextView sizeTextView = (TextView) rootView.findViewById(R.id.torrentSize);
        TextView ratioTextView = (TextView) rootView.findViewById(R.id.torrentRatio);
        TextView priorityTextView = (TextView) rootView.findViewById(R.id.torrentPriority);
        TextView stateTextView = (TextView) rootView.findViewById(R.id.torrentState);
        TextView leechsTextView = (TextView) rootView.findViewById(R.id.torrentLeechs);
        TextView seedsTextView = (TextView) rootView.findViewById(R.id.torrentSeeds);
        TextView progressTextView = (TextView) rootView.findViewById(R.id.torrentProgress);
        TextView hashTextView = (TextView) rootView.findViewById(R.id.torrentHash);

        TextView etaTextView = (TextView) rootView.findViewById(R.id.torrentEta);
        TextView uploadSpeedTextView = (TextView) rootView.findViewById(R.id.torrentUploadSpeed);
        TextView downloadSpeedTextView = (TextView) rootView.findViewById(R.id.torrentDownloadSpeed);

        CheckBox sequentialDownloadCheckBox;
        CheckBox firstLAstPiecePrioCheckBox;

        nameTextView.setText(name);
        ratioTextView.setText(ratio);
        stateTextView.setText(state);
        leechsTextView.setText(leechs);
        seedsTextView.setText(seeds);
        progressTextView.setText(progress);
        hashTextView.setText(hash);
        priorityTextView.setText(priority);
        etaTextView.setText(eta);

        if (MainActivity.qb_version.equals("3.2.x")) {
            sequentialDownloadCheckBox = (CheckBox) rootView.findViewById(R.id.torrentSequentialDownload);
            firstLAstPiecePrioCheckBox = (CheckBox) rootView.findViewById(R.id.torrentFirstLastPiecePrio);

            sequentialDownloadCheckBox.setChecked(torrent.getSequentialDownload());
            firstLAstPiecePrioCheckBox.setChecked(torrent.getisFirstLastPiecePrio());

            TextView addedOnTextView = (TextView) rootView.findViewById(R.id.torrentAddedOn);
            TextView completionOnTextView = (TextView) rootView.findViewById(R.id.torrentCompletionOn);

            TextView labelTextView = (TextView) rootView.findViewById(R.id.torrentLabel);

            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");

            if (addedOn != null && !(addedOn.equals("null")) && !(addedOn.equals("4294967295"))) {
                if (Integer.parseInt(MainActivity.qb_api) < 10) {
                    // Old time format 2016-07-25T20:52:07
                    addedOnTextView
                            .setText(new SimpleDateFormat("dd/MM/yyyy - HH:mm").format(sdf.parse(addedOn)));
                } else {
                    // New unix timestamp format 4294967295
                    addedOnTextView.setText(Common.timestampToDate(addedOn));
                }
            } else {
                addedOnTextView.setText("");
            }

            if (completionOn != null && !(completionOn.equals("null"))
                    && !(completionOn.equals("4294967295"))) {

                if (Integer.parseInt(MainActivity.qb_api) < 10) {
                    // Old time format 2016-07-25T20:52:07
                    completionOnTextView.setText(
                            new SimpleDateFormat("dd/MM/yyyy - HH:mm").format(sdf.parse(completionOn)));
                } else {
                    // New unix timestamp format 4294967295
                    completionOnTextView.setText(Common.timestampToDate(completionOn));
                }
            } else {
                completionOnTextView.setText("");
            }

            if (label != null && !(label.equals("null"))) {
                labelTextView.setText(label);
            } else {
                labelTextView.setText("");
            }

        }

        // Set Downloaded vs Total size
        sizeTextView.setText(downloaded + " / " + size);

        // Only for Pro version
        if (MainActivity.packageName.equals("com.lgallardo.qbittorrentclientpro")) {
            downloadSpeedTextView.setText(Character.toString('\u2193') + " " + downloadSpeed);
            uploadSpeedTextView.setText(Character.toString('\u2191') + " " + uploadSpeed);

            // Set progress bar
            ProgressBar progressBar = (ProgressBar) rootView.findViewById(R.id.progressBar1);
            TextView percentageTV = (TextView) rootView.findViewById(R.id.percentage);

            progressBar.setProgress(Integer.parseInt(percentage));
            percentageTV.setText(percentage + "%");

        } else {
            downloadSpeedTextView.setText(downloadSpeed);
            uploadSpeedTextView.setText(uploadSpeed);
        }

        nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_action_recheck, 0, 0, 0);

        if ("pausedUP".equals(state) || "pausedDL".equals(state)) {
            nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.paused, 0, 0, 0);
        }

        if ("stalledUP".equals(state)) {
            nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.stalledup, 0, 0, 0);
        }

        if ("stalledDL".equals(state)) {
            nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.stalleddl, 0, 0, 0);
        }

        if ("downloading".equals(state)) {
            nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.downloading, 0, 0, 0);
        }

        if ("uploading".equals(state) || "forcedUP".equals(state)) {
            nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.uploading, 0, 0, 0);
        }

        if ("queuedDL".equals(state) || "queuedUP".equals(state)) {
            nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.queued, 0, 0, 0);
        }

        if ("checkingDL".equals(state) || "checkingUP".equals(state)) {
            nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_action_recheck, 0, 0, 0);
        }

        if ("error".equals(state) || "missingFiles".equals(state) || "unknown".equals(state)) {
            nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.error, 0, 0, 0);
        }

        //            // Get Content files in background
        ContentFileTask cft = new ContentFileTask();
        cft.execute(new String[] { hash });

        // Get trackers in background
        TrackersTask tt = new TrackersTask();
        tt.execute(new String[] { hash });

        // Get General info labels
        generalInfoItems = new ArrayList<GeneralInfoItem>();

        generalInfoItems.add(new GeneralInfoItem(getString(R.string.torrent_details_save_path), null,
                GeneralInfoItem.GENERALINFO, "generalInfo"));
        generalInfoItems.add(new GeneralInfoItem(getString(R.string.torrent_details_created_date), null,
                GeneralInfoItem.GENERALINFO, "generalInfo"));
        generalInfoItems.add(new GeneralInfoItem(getString(R.string.torrent_details_comment), null,
                GeneralInfoItem.GENERALINFO, "generalInfo"));
        generalInfoItems.add(new GeneralInfoItem(getString(R.string.torrent_details_total_wasted), null,
                GeneralInfoItem.GENERALINFO, "generalInfo"));
        generalInfoItems.add(new GeneralInfoItem(getString(R.string.torrent_details_total_uploaded), null,
                GeneralInfoItem.GENERALINFO, "generalInfo"));
        generalInfoItems.add(new GeneralInfoItem(getString(R.string.torrent_details_total_downloaded), null,
                GeneralInfoItem.GENERALINFO, "generalInfo"));
        generalInfoItems.add(new GeneralInfoItem(getString(R.string.torrent_details_time_elapsed), null,
                GeneralInfoItem.GENERALINFO, "generalInfo"));
        generalInfoItems.add(new GeneralInfoItem(getString(R.string.torrent_details_num_connections), null,
                GeneralInfoItem.GENERALINFO, "generalInfo"));
        generalInfoItems.add(new GeneralInfoItem(getString(R.string.torrent_details_share_ratio), null,
                GeneralInfoItem.GENERALINFO, "generalInfo"));
        generalInfoItems.add(new GeneralInfoItem(getString(R.string.torrent_details_upload_rate_limit), null,
                GeneralInfoItem.GENERALINFO, "generalInfo"));
        generalInfoItems.add(new GeneralInfoItem(getString(R.string.torrent_details_download_rate_limit), null,
                GeneralInfoItem.GENERALINFO, "generalInfo"));

        // Get General info in background;
        GeneralInfoTask git = new GeneralInfoTask();
        git.execute(new String[] { hash });

    } catch (Exception e) {

        Log.e("Debug", "TorrentDetailsFragment - onCreateView: " + e.toString());
    }

}

From source file:org.onepf.opfiab.ComponentIabHelper.java

ComponentIabHelper(@Nullable final android.support.v4.app.FragmentManager supportFragmentManager,
        @Nullable final android.app.FragmentManager fragmentManager) {
    super();//from   w  w  w.jav  a 2s  . c  om
    // Register for lifecycle event right a way
    OPFIab.register(this);

    if (supportFragmentManager != null) {
        OPFLog.d("ComponentIabHelper uses android.support.v4.app.Fragment.");
        final android.support.v4.app.Fragment existingFragment = supportFragmentManager
                .findFragmentByTag(FRAGMENT_TAG);
        if (existingFragment != null) {
            // Fragment already attached
            opfFragment = existingFragment;
            register();
            return;
        }
        final android.support.v4.app.Fragment fragment = OPFIabSupportFragment.newInstance();
        opfFragment = fragment;
        // Attach new fragment
        supportFragmentManager.beginTransaction().add(fragment, FRAGMENT_TAG).commit();
        // wait for onAttach() callback
        supportFragmentManager.executePendingTransactions();
        return;
    }

    if (fragmentManager != null) {
        OPFLog.d("ComponentIabHelper uses android.app.Fragment.");
        final Fragment existingFragment = fragmentManager.findFragmentByTag(FRAGMENT_TAG);
        if (existingFragment != null) {
            opfFragment = existingFragment;
            register();
            return;
        }
        final Fragment fragment = OPFIabFragment.newInstance();
        opfFragment = fragment;
        fragmentManager.beginTransaction().add(fragment, FRAGMENT_TAG).commit();
        fragmentManager.executePendingTransactions();
        return;
    }

    throw new IllegalStateException();
}

From source file:com.lgallardo.youtorrentcontroller.TorrentDetailsFragment.java

public void updateDetails(Torrent torrent) {

    try {//from  w w w.  jav  a2s .  com

        // Hide herderInfo in phone's view
        if (getActivity().findViewById(R.id.one_frame) != null) {
            MainActivity.headerInfo.setVisibility(View.GONE);
        }

        // Get values from current activity
        name = torrent.getFile();
        size = torrent.getSize();
        hash = torrent.getHash();
        ratio = torrent.getRatio();
        state = torrent.getState();
        peersConnected = torrent.getPeersConnected();
        peersInSwarm = torrent.getPeersInSwarm();
        seedsConnected = torrent.getSeedsConnected();
        seedsInSwarm = torrent.getSeedInSwarm();
        progress = torrent.getProgress();
        priority = torrent.getPriority();
        eta = torrent.getEta();
        uploadSpeed = torrent.getUploadSpeed();
        downloadSpeed = torrent.getDownloadSpeed();
        downloaded = torrent.getDownloaded();

        int index = torrent.getProgress().indexOf(".");

        if (index == -1) {
            index = torrent.getProgress().indexOf(",");

            if (index == -1) {
                index = torrent.getProgress().length();
            }
        }

        percentage = torrent.getProgress().substring(0, index);

        int donwloadSpeedWeigth = torrent.getDownloadSpeedWeight();
        int uploadSpeedWeigth = torrent.getUploadSpeedWeight();

        FragmentManager fragmentManager = getFragmentManager();

        TorrentDetailsFragment detailsFragment = null;

        if (getActivity().findViewById(R.id.one_frame) != null) {
            detailsFragment = (TorrentDetailsFragment) fragmentManager.findFragmentByTag("firstFragment");
        } else {
            detailsFragment = (TorrentDetailsFragment) fragmentManager.findFragmentByTag("secondFragment");
        }

        View rootView = detailsFragment.getView();

        TextView nameTextView = (TextView) rootView.findViewById(R.id.torrentName);
        TextView sizeTextView = (TextView) rootView.findViewById(R.id.torrentSize);
        TextView ratioTextView = (TextView) rootView.findViewById(R.id.torrentRatio);
        TextView priorityTextView = (TextView) rootView.findViewById(R.id.torrentPriority);
        TextView stateTextView = (TextView) rootView.findViewById(R.id.torrentState);
        TextView leechsTextView = (TextView) rootView.findViewById(R.id.torrentLeechs);
        TextView seedsTextView = (TextView) rootView.findViewById(R.id.torrentSeeds);
        TextView progressTextView = (TextView) rootView.findViewById(R.id.torrentProgress);
        TextView hashTextView = (TextView) rootView.findViewById(R.id.torrentHash);

        TextView etaTextView = (TextView) rootView.findViewById(R.id.torrentEta);
        TextView uploadSpeedTextView = (TextView) rootView.findViewById(R.id.torrentUploadSpeed);
        TextView downloadSpeedTextView = (TextView) rootView.findViewById(R.id.torrentDownloadSpeed);

        CheckBox sequentialDownloadCheckBox;
        CheckBox firstLAstPiecePrioCheckBox;

        nameTextView.setText(name);
        ratioTextView.setText(ratio);
        stateTextView.setText(state);
        leechsTextView.setText("" + peersConnected + " (" + peersInSwarm + ")");
        seedsTextView.setText("" + seedsConnected + " (" + seedsInSwarm + ")");
        progressTextView.setText(progress);
        hashTextView.setText(hash);
        priorityTextView.setText(priority);
        etaTextView.setText(eta);

        // Set Downloaded vs Total size
        sizeTextView.setText(downloaded + " / " + size);

        // Only for Pro version
        if (MainActivity.packageName.equals("com.lgallardo.youtorrentcontrollerpro")) {
            downloadSpeedTextView.setText(Character.toString('\u2193') + " " + downloadSpeed);
            uploadSpeedTextView.setText(Character.toString('\u2191') + " " + uploadSpeed);

            // Set progress bar
            ProgressBar progressBar = (ProgressBar) rootView.findViewById(R.id.progressBar1);
            TextView percentageTV = (TextView) rootView.findViewById(R.id.percentage);

            progressBar.setProgress(Integer.parseInt(percentage));
            percentageTV.setText(percentage + "%");

        } else {
            downloadSpeedTextView.setText(downloadSpeed);
            uploadSpeedTextView.setText(uploadSpeed);
        }

        nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.error, 0, 0, 0);

        //            Log.d("Debug", "TorrentDetailsFragment - state: " + state);

        if ("paused".equals(state)) {
            nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.paused, 0, 0, 0);
        }

        if ("downloading".equals(state)) {
            nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.stalleddl, 0, 0, 0);

            if (donwloadSpeedWeigth > 0 || seedsConnected > 0 || peersConnected > 0) {
                nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.downloading, 0, 0, 0);
            }
        }

        if ("seeding".equals(state)) {
            nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.stalledup, 0, 0, 0);

            if (uploadSpeedWeigth > 0 || seedsConnected > 0 || peersConnected > 0) {
                nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.uploading, 0, 0, 0);
            }
        }

        if ("queued".equals(state)) {
            nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.queued, 0, 0, 0);
        }

        if ("checking".equals(state)) {
            nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_action_recheck, 0, 0, 0);
        }

        if ("stopped".equals(state)) {
            nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_action_stopped, 0, 0, 0);
        }

        //            // Get Content files in background
        //            qBittorrentContentFile qcf = new qBittorrentContentFile();
        //            qcf.execute(new View[]{rootView});
        //
        //            // Get trackers in background
        //            qBittorrentTrackers qt = new qBittorrentTrackers();
        //            qt.execute(new View[]{rootView});
        //
        //            // Get General info in background
        //            qBittorrentGeneralInfoTask qgit = new qBittorrentGeneralInfoTask();
        //            qgit.execute(new View[]{rootView});

    } catch (Exception e) {

        Log.e("Debug", "TorrentDetailsFragment - onCreateView: " + e.toString());
    }

}

From source file:com.zologic.tardis.app.MainActivity.java

private void restoreRetainedDataFragment() {
    // find the retained fragment
    FragmentManager fm = getFragmentManager();
    mRetainedDataFragment = (DataFragment) fm.findFragmentByTag(TAG);

    if (mRetainedDataFragment == null) {
        // Create
        mRetainedDataFragment = new DataFragment();
        fm.beginTransaction().add(mRetainedDataFragment, TAG).commitAllowingStateLoss(); // http://stackoverflow.com/questions/7575921/illegalstateexception-can-not-perform-this-action-after-onsaveinstancestate-h

        mScannedDevices = new ArrayList<>();

    } else {/*from   ww w  . j  ava  2  s . c o  m*/
        // Restore status
        mScannedDevices = mRetainedDataFragment.mScannedDevices;
        mComponentToStartWhenConnected = mRetainedDataFragment.mComponentToStartWhenConnected;
        mShouldEnableWifiOnQuit = mRetainedDataFragment.mShouldEnableWifiOnQuit;
        mFirmwareUpdater = mRetainedDataFragment.mFirmwareUpdater;
        mLatestCheckedDeviceAddress = mRetainedDataFragment.mLatestCheckedDeviceAddress;
        mSelectedDeviceData = mRetainedDataFragment.mSelectedDeviceData;

        if (mFirmwareUpdater != null) {
            mFirmwareUpdater.changedParentActivity(this); // set the new activity
        }
    }
}

From source file:com.example.nachiketvatkar.locateus.BluetoothPairing.java

private void restoreRetainedDataFragment() {
    // find the retained fragment
    FragmentManager fm = getFragmentManager();
    mRetainedDataFragment = (DataFragment) fm.findFragmentByTag(TAG);

    if (mRetainedDataFragment == null) {
        // Create
        mRetainedDataFragment = new DataFragment();
        fm.beginTransaction().add(mRetainedDataFragment, TAG).commitAllowingStateLoss(); // http://stackoverflow.com/questions/7575921/illegalstateexception-can-not-perform-this-action-after-onsaveinstancestate-h

        mScannedDevices = new ArrayList<>();

    } else {//from w ww.  ja va  2  s .c  o  m
        // Restore status
        mScannedDevices = mRetainedDataFragment.mScannedDevices;
        mComponentToStartWhenConnected = mRetainedDataFragment.mComponentToStartWhenConnected;
        mShouldEnableWifiOnQuit = mRetainedDataFragment.mShouldEnableWifiOnQuit;
        //            mFirmwareUpdater = mRetainedDataFragment.mFirmwareUpdater;
        mLatestCheckedDeviceAddress = mRetainedDataFragment.mLatestCheckedDeviceAddress;
        mSelectedDeviceData = mRetainedDataFragment.mSelectedDeviceData;

        //            if (mFirmwareUpdater != null) {
        //                mFirmwareUpdater.changedParentActivity(this);       // set the new activity
        //            }
    }
}