Search in sources :

Example 11 with AppCompatActivity

use of androidx.appcompat.app.AppCompatActivity in project ETSMobile-Android2 by ApplETS.

the class BottinFragment method updateUI.

@SuppressWarnings({ "rawtypes", "unchecked" })
void updateUI() {
    AppCompatActivity activity = (AppCompatActivity) getActivity();
    try {
        DatabaseHelper dbHelper = new DatabaseHelper(activity);
        // 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);
                    Collections.sort(listEmployesOfService, new Comparator<FicheEmploye>() {

                        @Override
                        public int compare(FicheEmploye f1, FicheEmploye f2) {
                            return f1.Nom.compareTo(f2.Nom);
                        }
                    });
                    listDataChild.put(previousNomService, listEmployesOfService);
                    listEmployesOfService = new ArrayList<>();
                    previousNomService = nomService;
                }
                listEmployesOfService.add(employe);
            }
            // Pour les derniers éléments dans la liste
            listDataChild.put(previousNomService, listEmployesOfService);
            if (activity != null) {
                activity.runOnUiThread(new Runnable() {

                    public void run() {
                        listAdapter = new ExpandableListAdapter(getActivity(), listDataHeader, listDataChild);
                        expListView.setAdapter(listAdapter);
                        listAdapter.notifyDataSetChanged();
                    }
                });
            }
            // Rétablissement du filtre de recherche
            CharSequence searchText = searchView.getQuery();
            if (searchText.length() != 0)
                onQueryTextChange(searchText.toString());
        // Si le contenu est vide, télécharger le bottin
        } else {
            // Le contenu est vide.
            afficherRafraichissementEtRechargerBottin();
        }
    } catch (Exception e) {
        Log.e("BD FicheEmploye", "" + e.getMessage());
    }
}
Also used : AppCompatActivity(androidx.appcompat.app.AppCompatActivity) ArrayList(java.util.ArrayList) ExpandableListAdapter(ca.etsmtl.applets.etsmobile.ui.adapter.ExpandableListAdapter) QueryBuilder(com.j256.ormlite.stmt.QueryBuilder) FicheEmploye(ca.etsmtl.applets.etsmobile.model.FicheEmploye) DatabaseHelper(ca.etsmtl.applets.etsmobile.db.DatabaseHelper)

Example 12 with AppCompatActivity

use of androidx.appcompat.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));
            startActivity(intent);
        }
    });
    return v;
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) ViewGroup(android.view.ViewGroup) AppCompatActivity(androidx.appcompat.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 13 with AppCompatActivity

use of androidx.appcompat.app.AppCompatActivity in project Douya by DreaminginCodeZH.

the class BroadcastFragment method onActivityCreated.

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    CustomTabsHelperFragment.attachTo(this);
    mResource = BroadcastAndCommentListResource.attachTo(mBroadcastId, mBroadcast, this);
    AppCompatActivity activity = (AppCompatActivity) getActivity();
    activity.setTitle(getTitle());
    activity.setSupportActionBar(mToolbar);
    mContainerLayout.setOnClickListener(view -> onFinish());
    ViewCompat.setTransitionName(mSharedView, Broadcast.makeTransitionName(mBroadcastId));
    // This magically gives better visual effect when the broadcast is partially visible. Using
    // setEnterSharedElementCallback() disables this hack when no transition is used to start
    // this Activity.
    ActivityCompat.setEnterSharedElementCallback(activity, new SharedElementCallback() {

        @Override
        public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
            mBroadcastCommentList.scrollToPosition(0);
        }
    });
    mToolbar.setOnDoubleClickListener(view -> {
        mBroadcastCommentList.smoothScrollToPosition(0);
        return true;
    });
    mSwipeRefreshLayout.setOnRefreshListener(() -> {
        mResource.loadBroadcast();
        mResource.loadCommentList(false);
    });
    mBroadcastCommentList.setHasFixedSize(true);
    mBroadcastCommentList.setItemAnimator(new NoChangeAnimationItemAnimator());
    mBroadcastCommentList.setLayoutManager(new LinearLayoutManager(activity));
    mBroadcastAdapter = new SingleBroadcastAdapter(null, this);
    // BroadcastLayout will take care of showing the effective broadcast.
    // noinspection deprecation
    setBroadcast(mResource.getBroadcast());
    mCommentAdapter = new CommentAdapter(mResource.getCommentList(), (parent, itemView, item, position) -> onShowCommentAction(item));
    mAdapter = new LoadMoreAdapter(mBroadcastAdapter, mCommentAdapter);
    mBroadcastCommentList.setAdapter(mAdapter);
    mBroadcastCommentList.addOnScrollListener(new OnVerticalScrollListener() {

        public void onScrolledToBottom() {
            mResource.loadCommentList(true);
        }
    });
    mSendButton.setOnClickListener(view -> onSendComment());
    TooltipUtils.setup(mSendButton);
    View.OnLongClickListener sendTooltipListener = mSendButton.getOnLongClickListener();
    mSendButton.setOnLongClickListener(view -> {
        if (!Settings.LONG_CLICK_TO_SHOW_SEND_COMMENT_ACTIVITY.getValue()) {
            return sendTooltipListener.onLongClick(view);
        }
        onShowSendCommentActivity();
        return true;
    });
    updateSendCommentStatus();
    if (savedInstanceState == null) {
        if (mShowSendComment) {
            TransitionUtils.postAfterTransition(this, this::onShowCommentIme);
        }
    }
    TransitionUtils.setEnterReturnExplode(this);
    TransitionUtils.setupTransitionOnActivityCreated(this);
}
Also used : ToastUtils(me.zhanghai.android.douya.util.ToastUtils) Bundle(android.os.Bundle) DoubleClickToolbar(me.zhanghai.android.douya.ui.DoubleClickToolbar) OnVerticalScrollListener(me.zhanghai.android.douya.ui.OnVerticalScrollListener) ProgressBar(android.widget.ProgressBar) FrameLayout(android.widget.FrameLayout) Comment(me.zhanghai.android.douya.network.api.info.frodo.Comment) LoadMoreAdapter(me.zhanghai.android.douya.ui.LoadMoreAdapter) GetOnLongClickListenerImageButton(me.zhanghai.android.douya.ui.GetOnLongClickListenerImageButton) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) BindView(butterknife.BindView) FragmentUtils(me.zhanghai.android.douya.util.FragmentUtils) ShareUtils(me.zhanghai.android.douya.util.ShareUtils) Fragment(androidx.fragment.app.Fragment) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) NoChangeAnimationItemAnimator(me.zhanghai.android.douya.ui.NoChangeAnimationItemAnimator) ViewCompat(androidx.core.view.ViewCompat) WebViewActivity(me.zhanghai.android.douya.ui.WebViewActivity) DeleteBroadcastManager(me.zhanghai.android.douya.broadcast.content.DeleteBroadcastManager) LikeBroadcastManager(me.zhanghai.android.douya.broadcast.content.LikeBroadcastManager) ConfirmDiscardContentDialogFragment(me.zhanghai.android.douya.ui.ConfirmDiscardContentDialogFragment) ThreadMode(org.greenrobot.eventbus.ThreadMode) ViewGroup(android.view.ViewGroup) DoubanUtils(me.zhanghai.android.douya.util.DoubanUtils) List(java.util.List) Nullable(androidx.annotation.Nullable) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) CustomTabsHelperFragment(me.zhanghai.android.customtabshelper.CustomTabsHelperFragment) EventBusUtils(me.zhanghai.android.douya.eventbus.EventBusUtils) ButterKnife(butterknife.ButterKnife) BroadcastCommentSentEvent(me.zhanghai.android.douya.eventbus.BroadcastCommentSentEvent) ApiError(me.zhanghai.android.douya.network.api.ApiError) FragmentFinishable(me.zhanghai.android.douya.ui.FragmentFinishable) MenuItem(android.view.MenuItem) Settings(me.zhanghai.android.douya.settings.info.Settings) ImeUtils(me.zhanghai.android.douya.util.ImeUtils) MenuInflater(android.view.MenuInflater) Menu(android.view.Menu) ClipboardUtils(me.zhanghai.android.douya.util.ClipboardUtils) LogUtils(me.zhanghai.android.douya.util.LogUtils) Broadcast(me.zhanghai.android.douya.network.api.info.frodo.Broadcast) TooltipUtils(me.zhanghai.android.douya.util.TooltipUtils) BroadcastCommentSendErrorEvent(me.zhanghai.android.douya.eventbus.BroadcastCommentSendErrorEvent) ActivityCompat(androidx.core.app.ActivityCompat) SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout) LayoutInflater(android.view.LayoutInflater) ViewUtils(me.zhanghai.android.douya.util.ViewUtils) DeleteBroadcastCommentManager(me.zhanghai.android.douya.broadcast.content.DeleteBroadcastCommentManager) TransitionUtils(me.zhanghai.android.douya.util.TransitionUtils) TextUtils(android.text.TextUtils) R(me.zhanghai.android.douya.R) BroadcastCommentCountFixer(me.zhanghai.android.douya.broadcast.content.BroadcastCommentCountFixer) RebroadcastBroadcastManager(me.zhanghai.android.douya.broadcast.content.RebroadcastBroadcastManager) Subscribe(org.greenrobot.eventbus.Subscribe) SendBroadcastCommentManager(me.zhanghai.android.douya.broadcast.content.SendBroadcastCommentManager) BroadcastAndCommentListResource(me.zhanghai.android.douya.broadcast.content.BroadcastAndCommentListResource) SharedElementCallback(androidx.core.app.SharedElementCallback) Activity(android.app.Activity) EditText(android.widget.EditText) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) OnVerticalScrollListener(me.zhanghai.android.douya.ui.OnVerticalScrollListener) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) BindView(butterknife.BindView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) SharedElementCallback(androidx.core.app.SharedElementCallback) LoadMoreAdapter(me.zhanghai.android.douya.ui.LoadMoreAdapter) NoChangeAnimationItemAnimator(me.zhanghai.android.douya.ui.NoChangeAnimationItemAnimator)

Example 14 with AppCompatActivity

use of androidx.appcompat.app.AppCompatActivity in project Douya by DreaminginCodeZH.

the class ProfileFragment method onActivityCreated.

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    CustomTabsHelperFragment.attachTo(this);
    mResource = ProfileResource.attachTo(mUserIdOrUid, mSimpleUser, mUser, this);
    mScrollLayout.setListener(new ProfileLayout.Listener() {

        @Override
        public void onEnterAnimationEnd() {
        }

        @Override
        public void onExitAnimationEnd() {
            getActivity().finish();
        }
    });
    if (savedInstanceState == null) {
        mScrollLayout.enter();
    }
    mDismissView.setOnClickListener(view -> exit());
    AppCompatActivity activity = (AppCompatActivity) getActivity();
    activity.setSupportActionBar(mToolbar);
    activity.getSupportActionBar().setTitle(null);
    if (mResource.hasUser()) {
        mHeaderLayout.bindUser(mResource.getUser());
    } else if (mResource.hasSimpleUser()) {
        mHeaderLayout.bindSimpleUser(mResource.getSimpleUser());
    }
    mHeaderLayout.setListener(this);
    mToolbar.setOnDoubleClickListener(view -> {
        if (!mScrollLayout.isHeaderCollapsed()) {
            return false;
        }
        mScrollLayout.animateHeaderViewScroll(false);
        return true;
    });
    if (ViewUtils.hasSw600Dp(activity)) {
        mContentList.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
    } else {
        mContentList.setLayoutManager(new LinearLayoutManager(activity));
    }
    mAdapter = new ProfileAdapter(this);
    mContentList.setAdapter(mAdapter);
    mContentStateLayout.setLoading();
    if (mResource.isAnyLoaded()) {
        mResource.notifyChangedIfLoaded();
    }
}
Also used : AppCompatActivity(androidx.appcompat.app.AppCompatActivity) StaggeredGridLayoutManager(androidx.recyclerview.widget.StaggeredGridLayoutManager) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager)

Example 15 with AppCompatActivity

use of androidx.appcompat.app.AppCompatActivity in project Douya by DreaminginCodeZH.

the class RebroadcastBroadcastFragment method onActivityCreated.

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    CustomTabsHelperFragment.attachTo(this);
    mBroadcastResource = BroadcastResource.attachTo(mBroadcastId, mBroadcast, this);
    AppCompatActivity activity = (AppCompatActivity) getActivity();
    activity.setSupportActionBar(mToolbar);
    if (savedInstanceState == null) {
        mTextEdit.setText(mText);
    }
    // noinspection deprecation
    if (mBroadcastResource.has()) {
        // noinspection deprecation
        setBroadcast(mBroadcastResource.get());
    }
    updateRebroadcastStatus();
}
Also used : AppCompatActivity(androidx.appcompat.app.AppCompatActivity)

Aggregations

AppCompatActivity (androidx.appcompat.app.AppCompatActivity)76 ActionBar (androidx.appcompat.app.ActionBar)23 View (android.view.View)20 Toolbar (androidx.appcompat.widget.Toolbar)19 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)10 TextView (android.widget.TextView)7 RecyclerView (androidx.recyclerview.widget.RecyclerView)7 Intent (android.content.Intent)6 Fragment (androidx.fragment.app.Fragment)6 BindView (butterknife.BindView)6 Activity (android.app.Activity)5 LayoutInflater (android.view.LayoutInflater)5 Bundle (android.os.Bundle)4 ImageView (android.widget.ImageView)4 ScrollView (android.widget.ScrollView)4 List (java.util.List)4 Nullable (androidx.annotation.Nullable)3 SuppressLint (android.annotation.SuppressLint)2 TargetApi (android.annotation.TargetApi)2 Dialog (android.app.Dialog)2