Search in sources :

Example 36 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project Atom_Android by Rogrand-Dev.

the class SimpleFragment method setToolBar.

protected void setToolBar(Toolbar toolbar, String title) {
    AppCompatActivity mAppCompatActivity = (AppCompatActivity) mActivity;
    toolbar.setTitle(title);
    mAppCompatActivity.setSupportActionBar(toolbar);
    if (mAppCompatActivity.getSupportActionBar() != null) {
        mAppCompatActivity.getSupportActionBar().setDisplayHomeAsUpEnabled(false);
        mAppCompatActivity.getSupportActionBar().setDisplayShowHomeEnabled(false);
    }
}
Also used : AppCompatActivity(android.support.v7.app.AppCompatActivity)

Example 37 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project ETSMobile-Android2 by ApplETS.

the class BottinFragment method updateUI.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
void updateUI() {
    // Get le contenu dans la bd
    AppCompatActivity activity = (AppCompatActivity) getActivity();
    DatabaseHelper dbHelper = new DatabaseHelper(activity);
    try {
        // Création du queryBuilder, permettant de lister les employés par leur nom de service
        QueryBuilder<FicheEmploye, String> queryBuilder = (QueryBuilder<FicheEmploye, String>) dbHelper.getDao(FicheEmploye.class).queryBuilder();
        queryBuilder.orderBy("Service", true);
        PreparedQuery<FicheEmploye> preparedQuery = queryBuilder.prepare();
        List<FicheEmploye> listEmployes = dbHelper.getDao(FicheEmploye.class).query(preparedQuery);
        // Si le contenu n'est pas vide, l'ajouter au listDataHeader et listDataChild
        if (listEmployes.size() > 0) {
            String nomService = "";
            String previousNomService = "";
            listDataHeader.clear();
            ArrayList<FicheEmploye> listEmployesOfService = new ArrayList<>();
            // Pour le premier élément dans la liste
            FicheEmploye employe = listEmployes.get(0);
            nomService = employe.Service;
            listDataHeader.add(nomService);
            listEmployesOfService.add(employe);
            previousNomService = nomService;
            // Pour les prochains éléments dans la liste
            for (int i = 1; i < listEmployes.size(); i++) {
                employe = listEmployes.get(i);
                nomService = employe.Service;
                if (!listDataHeader.contains(nomService)) {
                    listDataHeader.add(nomService);
                    listDataChild.put(previousNomService, listEmployesOfService);
                    listEmployesOfService = new ArrayList<>();
                    previousNomService = nomService;
                }
                listEmployesOfService.add(employe);
            }
            // Pour les derniers éléments dans la liste
            listDataChild.put(previousNomService, listEmployesOfService);
            listAdapter = new ExpandableListAdapter(getActivity(), listDataHeader, listDataChild);
            expListView.setAdapter(listAdapter);
            if (activity != null) {
                activity.runOnUiThread(new Runnable() {

                    public void run() {
                        listAdapter.notifyDataSetChanged();
                    }
                });
            }
        // Si le contenu est vide, télécharger le bottin
        } else {
            // Si l'appareil est connecté sur internet, télécharger le bottin en ligne
            if (Utility.isNetworkAvailable(getActivity())) {
                try {
                    mProgressDialog = ProgressDialog.show(getActivity(), null, getString(R.string.dialog_Loading_Directory), true);
                    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                    DataManager datamanager = DataManager.getInstance(getActivity());
                    datamanager.getDataFromSignet(DataManager.SignetMethods.BOTTIN_GET_LIST_SERVICE_AND_EMP, ApplicationManager.userCredentials, this);
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            // Si l'appareil n'est pas connecté sur internet, envoyer un message
            } else {
                Toast.makeText(getActivity(), getString(R.string.toast_Connection_Required), Toast.LENGTH_LONG).show();
            }
        }
    } catch (Exception e) {
        Log.e("BD FicheEmploye", e.getMessage());
    }
}
Also used : AppCompatActivity(android.support.v7.app.AppCompatActivity) ArrayList(java.util.ArrayList) ExpandableListAdapter(ca.etsmtl.applets.etsmobile.ui.adapter.ExpandableListAdapter) DataManager(ca.etsmtl.applets.etsmobile.http.DataManager) QueryBuilder(com.j256.ormlite.stmt.QueryBuilder) FicheEmploye(ca.etsmtl.applets.etsmobile.model.FicheEmploye) SQLException(java.sql.SQLException) SpiceException(com.octo.android.robospice.persistence.exception.SpiceException) DatabaseHelper(ca.etsmtl.applets.etsmobile.db.DatabaseHelper)

Example 38 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project ETSMobile-Android2 by ApplETS.

the class BandwithFragment method updateProgressBarColorItems.

private void updateProgressBarColorItems(double bandwidthQuota) {
    final int[] colorChoice = new int[] { R.color.red_bandwith, R.color.blue_bandwith, R.color.green_bandwith, R.color.purple_bandwith };
    int[] legendColors = new int[values.length];
    final AppCompatActivity activity = (AppCompatActivity) getActivity();
    progressBar.clearProgressItems();
    bandwidthQuota = bandwidthQuota / 1024;
    for (int i = 0, color = 0; i < values.length - 1; ++i) {
        ProgressItem progressItem = new ProgressItem(colorChoice[color], (values[i] / bandwidthQuota) * 100);
        progressBar.addProgressItem(progressItem);
        legendColors[i] = colorChoice[color];
        color++;
        if (color == colorChoice.length)
            color = 0;
    }
    if (values.length > 0) {
        int lastValue = values.length - 1;
        ProgressItem progressItem = new ProgressItem(R.color.grey_bandwith, (values[lastValue] / bandwidthQuota) * 100);
        legendColors[lastValue] = R.color.grey_bandwith;
        progressBar.addProgressItem(progressItem);
    }
    if (activity != null) {
        final int[] colors = legendColors;
        activity.runOnUiThread(new Runnable() {

            @Override
            public void run() {
                grid.setAdapter(new LegendAdapter(activity, rooms, colors));
            }
        });
    }
}
Also used : AppCompatActivity(android.support.v7.app.AppCompatActivity) ProgressItem(ca.etsmtl.applets.etsmobile.views.ProgressItem) LegendAdapter(ca.etsmtl.applets.etsmobile.ui.adapter.LegendAdapter)

Example 39 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project ETSMobile-Android2 by ApplETS.

the class SecuriteFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.security, container, false);
    final AppCompatActivity activity = (AppCompatActivity) getActivity();
    listView = (ListView) v.findViewById(android.R.id.list);
    final ViewGroup viewGroup = (ViewGroup) inflater.inflate(R.layout.secu_list_header, (ViewGroup) v.findViewById(R.id.secu_list_header_layout));
    listView.addHeaderView(viewGroup, null, false);
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(final AdapterView<?> arg0, final View arg1, final int arg2, final long arg3) {
            final Intent intent = new Intent(activity, UrgenceActivity.class);
            intent.putExtra("id", arg2);
            startActivity(intent);
        }
    });
    listView.setAdapter(new ArrayAdapter<String>(activity, R.layout.row_text_with_arrow, R.id.titleTextView, activity.getResources().getStringArray(R.array.secu_urgence)));
    viewGroup.findViewById(R.id.secu_list_header_phone).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(final View v) {
            final String phoneNumber = ((TextView) v).getText().toString();
            final String uri = "tel:" + phoneNumber.trim();
            final Intent intent = new Intent(Intent.ACTION_DIAL);
            intent.setData(Uri.parse(uri));
            AnalyticsHelper.getInstance(getActivity()).sendActionEvent(getClass().getSimpleName(), UrgenceActivity.APPEL_D_URGENCE);
            startActivity(intent);
        }
    });
    AnalyticsHelper.getInstance(getActivity()).sendScreenEvent(getClass().getSimpleName());
    return v;
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) ViewGroup(android.view.ViewGroup) AppCompatActivity(android.support.v7.app.AppCompatActivity) Intent(android.content.Intent) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) UrgenceActivity(ca.etsmtl.applets.etsmobile.ui.activity.UrgenceActivity) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView)

Example 40 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project Douya by DreaminginCodeZH.

the class TintHelper method onPanelMenuCreated.

public static void onPanelMenuCreated(int featureId, Menu menu, AppCompatActivity activity) {
    if (featureId == Window.FEATURE_OPTIONS_PANEL) {
        Context context = activity.getSupportActionBar().getThemedContext();
        ColorStateList menuTintList = ViewUtils.getColorStateListFromAttrRes(R.attr.colorControlNormal, context);
        int popupThemeResId = ViewUtils.getResIdFromAttrRes(R.attr.popupTheme, 0, context);
        ColorStateList subMenuTintList;
        if (popupThemeResId != 0) {
            Context popupContext = new ContextThemeWrapper(context, popupThemeResId);
            subMenuTintList = ViewUtils.getColorStateListFromAttrRes(R.attr.colorControlNormal, popupContext);
        } else {
            subMenuTintList = menuTintList;
        }
        tintMenuItemIcon(menu, menuTintList, subMenuTintList);
    }
}
Also used : Context(android.content.Context) ContextThemeWrapper(android.support.v7.view.ContextThemeWrapper) ColorStateList(android.content.res.ColorStateList)

Aggregations

AppCompatActivity (android.support.v7.app.AppCompatActivity)99 View (android.view.View)43 ActionBar (android.support.v7.app.ActionBar)36 TextView (android.widget.TextView)28 RecyclerView (android.support.v7.widget.RecyclerView)21 ImageView (android.widget.ImageView)17 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)16 Toolbar (android.support.v7.widget.Toolbar)14 BindView (butterknife.BindView)11 Fragment (android.support.v4.app.Fragment)8 PopupMenu (android.support.v7.widget.PopupMenu)8 Transition (android.transition.Transition)7 MenuItem (android.view.MenuItem)7 Intent (android.content.Intent)6 FragmentTransaction (android.support.v4.app.FragmentTransaction)6 TargetApi (android.annotation.TargetApi)5 Activity (android.app.Activity)4 ColorDrawable (android.graphics.drawable.ColorDrawable)4 Bundle (android.os.Bundle)4 FragmentManager (android.support.v4.app.FragmentManager)4