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());
}
}
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;
}
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);
}
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();
}
}
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();
}
Aggregations