Example usage for android.widget TabHost getCurrentView

List of usage examples for android.widget TabHost getCurrentView

Introduction

In this page you can find the example usage for android.widget TabHost getCurrentView.

Prototype

public View getCurrentView() 

Source Link

Usage

From source file:de.hshannover.f4.trust.ironcontrol.view.SubscribeFragmentActivity.java

public void subscribe(View view) {
    FragmentManager fm = getSupportFragmentManager();
    Fragment tabsFragment = fm.findFragmentById(R.id.tabs_fragment);
    TabHost tabHost = (TabHost) tabsFragment.getView().findViewById(android.R.id.tabhost);

    if (tabHost.getCurrentView().getId() == R.id.tab1) {
        //Simple Subscribe
        SimpleRequestFragment fSimple = (SimpleRequestFragment) fm.findFragmentByTag(TabFragment.TAB_SIMPLE);
        fSimple.subscription(view);//w w w.  j a  v  a2s  .c  o  m

    } else if (tabHost.getCurrentView().getId() == R.id.tab2) {
        //Advanced Subscribe
        AdvancedRequestFragment fAdvanced = (AdvancedRequestFragment) fm
                .findFragmentByTag(TabFragment.TAB_ADVANCED);
        fAdvanced.subscription(view);
    }
}

From source file:de.hshannover.f4.trust.ironcontrol.view.SubscribeFragmentActivity.java

public void saveSubscribtion(View view) {
    FragmentManager fm = getSupportFragmentManager();
    Fragment tabsFragment = fm.findFragmentById(R.id.tabs_fragment);
    TabHost tabHost = (TabHost) tabsFragment.getView().findViewById(android.R.id.tabhost);

    if (tabHost.getCurrentView().getId() == R.id.tab1) {
        //Simple Subscribe
        SimpleRequestFragment fSimple = (SimpleRequestFragment) fm.findFragmentByTag(TabFragment.TAB_SIMPLE);
        fSimple.createSubscribeSaveDialog().show();

    } else if (tabHost.getCurrentView().getId() == R.id.tab2) {
        //Advanced Subscribe
        AdvancedRequestFragment fAdvanced = (AdvancedRequestFragment) fm
                .findFragmentByTag(TabFragment.TAB_ADVANCED);
        fAdvanced.createSubscribeSaveDialog().show();
    }//  w  ww  .j a  va  2  s  .c  o m
}

From source file:de.hshannover.f4.trust.ironcontrol.view.SearchFragmentActivity.java

public void search(View view) {
    FragmentManager fm = getSupportFragmentManager();
    Fragment tabsFragment = fm.findFragmentById(R.id.tabs_fragment);
    TabHost tabHost = (TabHost) tabsFragment.getView().findViewById(android.R.id.tabhost);

    if (tabHost.getCurrentView().getId() == R.id.tab1) {
        //Simple Search
        SimpleRequestFragment fSimple = (SimpleRequestFragment) fm.findFragmentByTag(TabFragment.TAB_SIMPLE);
        fSimple.search(view);/* w  w w  .j  av  a  2  s.  co m*/

    } else if (tabHost.getCurrentView().getId() == R.id.tab2) {
        //Advanced Search
        AdvancedRequestFragment fAdvanced = (AdvancedRequestFragment) fm
                .findFragmentByTag(TabFragment.TAB_ADVANCED);
        fAdvanced.search(view);
    }
}

From source file:de.hshannover.f4.trust.ironcontrol.view.SearchFragmentActivity.java

public void saveSearch(View view) {
    FragmentManager fm = getSupportFragmentManager();
    Fragment tabsFragment = fm.findFragmentById(R.id.tabs_fragment);
    TabHost tabHost = (TabHost) tabsFragment.getView().findViewById(android.R.id.tabhost);

    if (tabHost.getCurrentView().getId() == R.id.tab1) {
        //Simple Search
        SimpleRequestFragment fSimple = (SimpleRequestFragment) fm.findFragmentByTag(TabFragment.TAB_SIMPLE);
        fSimple.createSearchSaveDialog().show();

    } else if (tabHost.getCurrentView().getId() == R.id.tab2) {
        //Advanced Search
        AdvancedRequestFragment fAdvanced = (AdvancedRequestFragment) fm
                .findFragmentByTag(TabFragment.TAB_ADVANCED);
        fAdvanced.createSearchSaveDialog().show();
    }// w  w  w . jav  a2 s . c o m
}

From source file:com.tutor.fragment.ViewPageFragment.java

private void setFDListViewAdapter(TabHost tabHost) {
    View view = (View) tabHost.getCurrentView();
    ListView listView = (ListView) view.findViewById(R.id.lv_products);
    listView.setAdapter(new ProductListAdapter(getActivity(), listItems));
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override/*from  w ww  . j  a va2 s  .  com*/
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent intent = new Intent(getActivity(), AppDetailActivity.class);
            setCurrentFDItemInf(position);
            intent.putExtra("position", position);
            startActivity(intent);
        }
    });
}

From source file:com.tutor.fragment.ViewPageFragment.java

private void setJFListViewAdapter(TabHost tabHost) {
    View view = (View) tabHost.getCurrentView();
    ListView listView = (ListView) view.findViewById(R.id.lv_products);
    listView.setAdapter(new JFListAdapter(getActivity(), jf_listItems));
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override//from   www  .j  av  a  2 s  .c  om
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent intent = new Intent(getActivity(), JfAppDetailActivity.class);
            setCurrentJFItemInf(position);
            intent.putExtra("position", position);
            startActivity(intent);
        }
    });
}

From source file:org.runnerup.view.MainLayout.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    setContentView(R.layout.main);/*w  ww. j  av  a  2s.co  m*/

    int versionCode = 0;
    UpgradeState upgradeState = UpgradeState.UNKNOWN;
    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
    Editor editor = pref.edit();
    try {
        PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
        versionCode = pInfo.versionCode;
        int version = pref.getInt("app-version", -1);
        if (version == -1) {
            upgradeState = UpgradeState.NEW;
        } else if (versionCode == version) {
            upgradeState = UpgradeState.SAME;
        } else if (versionCode > version) {
            upgradeState = UpgradeState.UPGRADE;
        } else if (versionCode < version) {
            upgradeState = UpgradeState.DOWNGRADE;
        }
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }
    editor.putInt("app-version", versionCode);
    boolean km = Formatter.getUseKilometers(getResources(), pref, editor);

    if (upgradeState == UpgradeState.NEW) {
        editor.putString(getResources().getString(R.string.pref_autolap),
                Double.toString(km ? Formatter.km_meters : Formatter.mi_meters));
    }
    editor.commit();

    // clear basicTargetType between application startup/shutdown
    pref.edit().remove(getString(R.string.pref_basic_target_type)).commit();

    Log.e(getClass().getName(),
            "app-version: " + versionCode + ", upgradeState: " + upgradeState + ", km: " + km);

    // convert pref_mute to pref_mute_bool
    Resources res = getResources();
    try {
        if (pref.contains(res.getString(R.string.pref_mute))) {
            String v = pref.getString(res.getString(R.string.pref_mute), "no");
            editor.putBoolean(res.getString(R.string.pref_mute_bool), v.equalsIgnoreCase("yes"));
            editor.remove(res.getString(R.string.pref_mute));
            editor.commit();
        }
    } catch (Exception e) {
    }

    PreferenceManager.setDefaultValues(this, R.xml.settings, false);
    PreferenceManager.setDefaultValues(this, R.xml.audio_cue_settings, true);

    TabHost tabHost = getTabHost(); // The activity TabHost

    tabHost.addTab(tabHost.newTabSpec("Start")
            .setIndicator(getString(R.string.Start), myGetDrawable(R.drawable.ic_tab_main))
            .setContent(new Intent(this, StartActivity.class)));

    tabHost.addTab(tabHost.newTabSpec("Feed")
            .setIndicator(getString(R.string.feed), myGetDrawable(R.drawable.ic_tab_feed))
            .setContent(new Intent(this, FeedActivity.class)));

    tabHost.addTab(tabHost.newTabSpec("History")
            .setIndicator(getString(R.string.History), myGetDrawable(R.drawable.ic_tab_history))
            .setContent(new Intent(this, HistoryActivity.class)));

    tabHost.addTab(tabHost.newTabSpec("Settings")
            .setIndicator(getString(R.string.Settings), myGetDrawable(R.drawable.ic_tab_setup))
            .setContent(new Intent(this, SettingsActivity.class)));

    tabHost.setCurrentTab(0);
    WidgetUtil.addLegacyOverflowButton(getWindow());

    if (upgradeState == UpgradeState.UPGRADE) {
        whatsNew();
    }
    //GPS is essential, always nag user if not granted
    requestGpsPermissions(this, tabHost.getCurrentView());

    //Import workouts/schemes. No permission needed
    handleBundled(getApplicationContext().getAssets(), "bundled", getFilesDir().getPath() + "/..");

    // if we were called from an intent-filter because user opened "runnerup.db.export", load it
    final Uri data = getIntent().getData();
    if (data != null) {
        if (SettingsActivity.requestReadStoragePermissions(MainLayout.this)) {
            String filePath = null;
            if ("content".equals(data.getScheme())) {
                Cursor cursor = this.getContentResolver().query(data,
                        new String[] { android.provider.MediaStore.Images.ImageColumns.DATA }, null, null,
                        null);
                cursor.moveToFirst();
                filePath = cursor.getString(0);
                cursor.close();
            } else {
                filePath = data.getPath();
            }
            Log.i(getClass().getSimpleName(), "Importing database from " + filePath);
            DBHelper.importDatabase(MainLayout.this, filePath);
        } else {
            Toast.makeText(this, "Storage permission not granted in Android settings, db is not imported.",
                    Toast.LENGTH_SHORT).show();
        }
    }
}