public void removeAt(final View view, final int position) { // No cambia de color view.setBackgroundColor(fragment.getResources().getColor(R.color.colorDarkGrey)); Vibrator v = (Vibrator) fragment.getContext().getSystemService(Context.VIBRATOR_SERVICE); // Vibrate for 500 milliseconds v.vibrate(50); new AlertDialog.Builder(fragment.getContext()) .setMessage("Sure you want to delete?") .setNegativeButton( "No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); view.setBackgroundColor(fragment.getResources().getColor(R.color.windowBackground)); } }) .setPositiveButton( "Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); SQL sql = new SQL(fragment.getContext()); fragment.list.remove(position); sql.resetScore(users.get(position).getEmail(), fragment.getSizeName()); users.remove(position); notifyItemRemoved(position); notifyItemRangeChanged(position, users.size()); if (position == 0) fragment.updateTopCard(); } }) .setIcon(android.R.drawable.ic_dialog_alert) .show(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_round_tab); ButterKnife.bind(this); mNavigationBar .setDisplayBackButton(true) .setBackButtonImageResource(R.drawable.ic_chevron_left_white_24dp) .setBackButtonText("Back") .setOnBackButtonClickListener( new View.OnClickListener() { @Override public void onClick(View v) { onBackPressed(); } }) .addItem(0, "Settings", ActivityCompat.getDrawable(this, R.drawable.ic_settings_white_24dp)) .addItem(1, "More", ActivityCompat.getDrawable(this, R.drawable.ic_more_vert_white_24dp)) .setOnMenuItemClickListener( new NavigationBar.OnMenuItemClickListener() { @Override public void onMenuItemClick(int id) { Toast.makeText(getApplicationContext(), "" + id, Toast.LENGTH_SHORT).show(); } }) .setTabs(new String[] {"music", "video", "games"}) .setOnTabCheckedListener( new NavigationBar.OnTabCheckedListener() { @Override public void onTabChecked(int position) { Toast.makeText( getApplicationContext(), "Tab " + position + " is checked", Toast.LENGTH_SHORT) .show(); } }) .bindViewPager(mViewPager); mFragmentList.add(TabFragment.newInstance(TAB_NANES[0])); mFragmentList.add(TabFragment.newInstance(TAB_NANES[1])); mFragmentList.add(TabFragment.newInstance(TAB_NANES[2])); mViewPagerAdapter = new ViewPagerAdapter(getSupportFragmentManager()); mViewPager.setAdapter(mViewPagerAdapter); mSearchView.setImeOption(EditorInfo.IME_ACTION_SEARCH); mSearchView.setOnEditorActionListener(mOnEditorActionListener); mSearchView.setOnFocusChangeListener(mOnFocusChangeListener); mSearchView.setButtonTextColor(BG_COLOR); mSearchView.setHint("Search"); mSearchView.setHintTextColor(0xFF8E8E93); mSearchView.setButtonText("Cancel"); mSearchView.setStyle(SearchView.Style.ROUND); }
@Override protected void handleReceiver(Context context, Intent intent) { super.handleReceiver(context, intent); if (intent.getAction().equals(new String[] {getActivity().getPackageName() + ".inited"})) { GroupService.syncGroup(this); } else if (IMessageSqlManager.ACTION_GROUP_DEL.equals(intent.getAction())) { onSyncGroup(); } }
@Override public void onResume() { super.onResume(); GroupSqlManager.registerGroupObserver(mGroupAdapter); mGroupAdapter.notifyChange(); if (!sync) { GroupService.syncGroup(this); sync = true; } }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (mListView != null) { mListView.setAdapter(null); } mListView = (ListView) findViewById(R.id.group_list); View emptyView = findViewById(R.id.empty_tip_tv); mListView.setEmptyView(emptyView); mListView.setOnItemClickListener(onItemClickListener); mGroupAdapter = new GroupAdapter(getActivity()); mListView.setAdapter(mGroupAdapter); findViewById(R.id.loading_tips_area).setVisibility(View.GONE); registerReceiver( new String[] { getActivity().getPackageName() + ".inited", IMessageSqlManager.ACTION_GROUP_DEL }); }
private void initDatas() { mIndicator.setTitles(mTitles); for (int i = 0; i < mTitles.length; i++) { mFragments[i] = (TabFragment) TabFragment.newInstance(mTitles[i]); } mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) { @Override public int getCount() { return mTitles.length; } @Override public Fragment getItem(int position) { return mFragments[position]; } }; mViewPager.setAdapter(mAdapter); mViewPager.setCurrentItem(0); }
@Override public void onPause() { super.onPause(); GroupSqlManager.unregisterGroupObserver(mGroupAdapter); }