Java Code Examples for androidx.appcompat.app.AppCompatActivity#findViewById()

The following examples show how to use androidx.appcompat.app.AppCompatActivity#findViewById() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AddCardViewUnitTest.java    From braintree-android-drop-in with MIT License 6 votes vote down vote up
@Test
public void cardNumberIsRestoredOnConfigurationChange() {
    mView.getCardForm().getCardEditText().setText(VISA);

    Bundle bundle = new Bundle();
    mActivityController.saveInstanceState(bundle)
            .pause()
            .stop()
            .destroy();
    mActivityController = Robolectric.buildActivity(UnitTestActivity.class)
            .setup(bundle);
    mActivity = (AppCompatActivity) mActivityController.get();
    mView = mActivity.findViewById(R.id.bt_add_card_view);
    mView.setup(mActivity, (Configuration) basicConfig(), true);

    assertEquals(VISA, mView.getCardForm().getCardNumber());
}
 
Example 2
Source File: NavigationDrawerFragment.java    From bitmask_android with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Users of this fragment must call this method to set up the navigation drawer interactions.
 *
 * @param fragmentId   The android:id of this fragment in its activity's layout.
 * @param drawerLayout The DrawerLayout containing this fragment's UI.
 */
public void setUp(int fragmentId, DrawerLayout drawerLayout) {
    final AppCompatActivity activity = (AppCompatActivity) getActivity();
    fragmentContainerView = activity.findViewById(fragmentId);
    this.drawerLayout = drawerLayout;
    // set a custom shadow that overlays the main content when the drawer opens
    this.drawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    toolbar = this.drawerLayout.findViewById(R.id.toolbar);

    setupActionBar();
    setupEntries();
    setupActionBarDrawerToggle(activity);

    if (!userLearnedDrawer) {
        openNavigationDrawerForFirstTimeUsers();
    }

    // Defer code dependent on restoration of previous instance state.
    this.drawerLayout.post(() -> drawerToggle.syncState());
    this.drawerLayout.addDrawerListener(drawerToggle);
}
 
Example 3
Source File: ChatsFragment.java    From toktok-android with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onCreateActionMode(@NonNull final ActionMode mode, Menu menu) {
    final AppCompatActivity activity = (AppCompatActivity) getActivity();
    mAppLayout = activity.findViewById(R.id.appBarLayout);
    mAppLayout.setBackgroundColor(CompatUtil.getColor(getResources(), R.color.backgroundColor));

    mFab = activity.findViewById(R.id.home_fab);
    mFab.setBackgroundTintList(ColorStateList.valueOf(CompatUtil.getColor(getResources(), R.color.textDarkColor)));
    mFab.setImageResource(R.drawable.ic_action_delete);
    mFab.setImageTintList(ColorStateList.valueOf(CompatUtil.getColor(getResources(), R.color.textWhiteColor)));

    mCustomViewPager = activity.findViewById(R.id.home_tab_holder);
    mCustomViewPager.setSwipingEnabled(false);

    mFab.setOnClickListener(v -> {
        mChatsRecyclerAdapter.deleteSelected();

        new Handler().postDelayed(() -> mode.finish(), 500);
    });

    return true;
}
 
Example 4
Source File: HoneycombUtil.java    From shortyz with GNU General Public License v3.0 6 votes vote down vote up
@Override
  public void finishOnHomeButton(final AppCompatActivity a) {
ActionBar bar = a.getSupportActionBar();
if(bar == null){
	return;
}

bar.setDisplayHomeAsUpEnabled(true);
View home = a.findViewById(android.R.id.home);
      if(home != null){
       home.setOnClickListener(new OnClickListener() {
               public void onClick(View arg0) {
                   a.onBackPressed();
               }
           });
      }
  }
 
Example 5
Source File: AccPersonalFragment.java    From tindroid with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    final AppCompatActivity activity = (AppCompatActivity) getActivity();
    if (activity == null) {
        return  null;
    }
    // Inflate the fragment layout
    View fragment = inflater.inflate(R.layout.fragment_acc_personal, container, false);
    final ActionBar bar = activity.getSupportActionBar();
    if (bar != null) {
        bar.setDisplayHomeAsUpEnabled(true);
    }

    Toolbar toolbar = activity.findViewById(R.id.toolbar);
    toolbar.setTitle(R.string.general);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            activity.getSupportFragmentManager().popBackStack();
        }
    });

    return fragment;
}
 
Example 6
Source File: AccNotificationsFragment.java    From tindroid with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    final AppCompatActivity activity = (AppCompatActivity) getActivity();
    if (activity == null) {
        return null;
    }
    // Inflate the fragment layout
    View fragment = inflater.inflate(R.layout.fragment_acc_notifications, container, false);
    final ActionBar bar = activity.getSupportActionBar();
    if (bar != null) {
        bar.setDisplayHomeAsUpEnabled(true);
    }

    Toolbar toolbar = activity.findViewById(R.id.toolbar);
    toolbar.setTitle(R.string.account_settings);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            activity.getSupportFragmentManager().popBackStack();
        }
    });

    return fragment;
}
 
Example 7
Source File: AccSecurityFragment.java    From tindroid with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    final AppCompatActivity activity = (AppCompatActivity) getActivity();
    if (activity == null) {
        return  null;
    }
    // Inflate the fragment layout
    View fragment = inflater.inflate(R.layout.fragment_acc_security, container, false);
    final ActionBar bar = activity.getSupportActionBar();
    if (bar != null) {
        bar.setDisplayHomeAsUpEnabled(true);
    }

    Toolbar toolbar = activity.findViewById(R.id.toolbar);
    toolbar.setTitle(R.string.security);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            activity.getSupportFragmentManager().popBackStack();
        }
    });

    return fragment;
}
 
Example 8
Source File: AnimatedButtonViewUnitTest.java    From braintree-android-drop-in with MIT License 5 votes vote down vote up
@Before
public void setup() {
    UnitTestActivity.view = R.layout.bt_add_card_activity;
    AppCompatActivity activity = Robolectric.buildActivity(UnitTestActivity.class)
            .setup()
            .get();
    mView = activity.findViewById(R.id.bt_animated_button_view);
}
 
Example 9
Source File: AddCardViewUnitTest.java    From braintree-android-drop-in with MIT License 5 votes vote down vote up
@Before
public void setup() {
    UnitTestActivity.view = R.layout.bt_add_card_activity;
    mActivityController = Robolectric.buildActivity(UnitTestActivity.class);
    mActivity = (AppCompatActivity) mActivityController.setup().get();
    mView = mActivity.findViewById(R.id.bt_add_card_view);
    mView.setup(mActivity, (Configuration) new TestConfigurationBuilder()
            .creditCards(new TestConfigurationBuilder.TestCardConfigurationBuilder()
                    .supportedCardTypes(PaymentMethodType.VISA.getCanonicalName()))
            .buildConfiguration(), false);
}
 
Example 10
Source File: EnrollmentCardViewUnitTest.java    From braintree-android-drop-in with MIT License 5 votes vote down vote up
@Before
public void setup() {
    UnitTestActivity.view = R.layout.bt_add_card_activity;
    mActivityController = Robolectric.buildActivity(UnitTestActivity.class);
    mActivity = (AppCompatActivity) mActivityController.setup().get();
    mView = mActivity.findViewById(R.id.bt_enrollment_card_view);
}
 
Example 11
Source File: EditCardViewUnitTest.java    From braintree-android-drop-in with MIT License 5 votes vote down vote up
@Before
public void setup() {
    UnitTestActivity.view = R.layout.bt_add_card_activity;
    mActivityController = Robolectric.buildActivity(UnitTestActivity.class);
    mActivity = (AppCompatActivity) mActivityController.setup().get();
    mView = mActivity.findViewById(R.id.bt_edit_card_view);
}
 
Example 12
Source File: AccNotificationsFragment.java    From tindroid with Apache License 2.0 5 votes vote down vote up
@Override
public void updateFormValues(final AppCompatActivity activity, final MeTopic<VxCard> me) {
    if (activity == null || me == null) {
        return;
    }

    // Incognito mode
    Switch ctrl = activity.findViewById(R.id.switchIncognitoMode);
    ctrl.setChecked(me.isMuted());
}
 
Example 13
Source File: PlayingQueueAdapter.java    From VinylMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
public static int getBackgroundColor(AppCompatActivity activity){
    //TODO: Find a better way to get the album background color
    TextView tV = activity.findViewById(R.id.player_queue_sub_header);
    if(tV != null){
        return tV.getCurrentTextColor();
    } else {
        return ATHUtil.resolveColor(activity, R.attr.cardBackgroundColor);
    }
}
 
Example 14
Source File: AccountInfoFragment.java    From tindroid with Apache License 2.0 5 votes vote down vote up
@Override
public void updateFormValues(final AppCompatActivity activity, final MeTopic<VxCard> me) {
    if (activity == null) {
        return;
    }

    ((TextView) activity.findViewById(R.id.topicAddress)).setText(Cache.getTinode().getMyId());

    String fn = null;
    if (me != null) {
        VxCard pub = me.getPub();
        if (pub != null) {
            fn = pub.fn;
            final Bitmap bmp = pub.getBitmap();
            if (bmp != null) {
                ((AppCompatImageView) activity.findViewById(R.id.imageAvatar))
                        .setImageDrawable(new RoundImageDrawable(getResources(), bmp));
            }
        }
    }

    final TextView title = activity.findViewById(R.id.topicTitle);
    if (!TextUtils.isEmpty(fn)) {
        title.setText(fn);
        title.setTypeface(null, Typeface.NORMAL);
        title.setTextIsSelectable(true);
    } else {
        title.setText(R.string.placeholder_contact_title);
        title.setTypeface(null, Typeface.ITALIC);
        title.setTextIsSelectable(false);
    }
}
 
Example 15
Source File: AccAboutFragment.java    From tindroid with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    final AppCompatActivity activity = (AppCompatActivity) getActivity();
    if (activity == null) {
        return  null;
    }
    // Inflate the fragment layout
    View fragment = inflater.inflate(R.layout.dialog_about, container, false);
    final ActionBar bar = activity.getSupportActionBar();
    if (bar != null) {
        bar.setDisplayHomeAsUpEnabled(true);
    }

    Toolbar toolbar = activity.findViewById(R.id.toolbar);
    toolbar.setTitle(R.string.about_the_app);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            activity.getSupportFragmentManager().popBackStack();
        }
    });

    ((TextView) fragment.findViewById(R.id.app_version)).setText(TindroidApp.getAppVersion());
    ((TextView) fragment.findViewById(R.id.app_build)).setText(String.format(Locale.US, "%d", TindroidApp.getAppBuild()));
    ((TextView) fragment.findViewById(R.id.app_server)).setText(Cache.getTinode().getHttpOrigin());

    return fragment;
}
 
Example 16
Source File: FirebaseHelper.java    From UberClone with MIT License 5 votes vote down vote up
public FirebaseHelper(AppCompatActivity activity){
    this.activity=activity;
    root=activity.findViewById(R.id.root);
    firebaseAuth=FirebaseAuth.getInstance();
    firebaseDatabase=FirebaseDatabase.getInstance();
    users=firebaseDatabase.getReference(Common.user_rider_tbl);
    if(firebaseAuth.getUid()!=null)loginSuccess();
}
 
Example 17
Source File: FirebaseHelper.java    From UberClone with MIT License 5 votes vote down vote up
public FirebaseHelper(AppCompatActivity activity){
    this.activity=activity;
    root=activity.findViewById(R.id.root);
    firebaseAuth=FirebaseAuth.getInstance();
    firebaseDatabase=FirebaseDatabase.getInstance();
    users=firebaseDatabase.getReference(Common.user_driver_tbl);
    if(firebaseAuth.getUid()!=null)loginSuccess();
}
 
Example 18
Source File: TapIntroHelper.java    From candybar with Apache License 2.0 4 votes vote down vote up
public static void showIconsIntro(@NonNull Context context) {
    if (Preferences.get(context).isTimeToShowIconsIntro()) {
        AppCompatActivity activity = (AppCompatActivity) context;

        Toolbar toolbar = activity.findViewById(R.id.toolbar);
        if (toolbar == null) return;

        new Handler().postDelayed(() -> {
            try {
                int primary = ColorHelper.getAttributeColor(context, R.attr.toolbar_icon);
                int secondary = ColorHelper.setColorAlpha(primary, 0.7f);

                Typeface title = TypefaceHelper.getMedium(context);
                Typeface description = TypefaceHelper.getRegular(context);

                TapTarget tapTarget = TapTarget.forToolbarMenuItem(toolbar, R.id.menu_search,
                        context.getResources().getString(R.string.tap_intro_icons_search),
                        context.getResources().getString(R.string.tap_intro_icons_search_desc))
                        .titleTextColorInt(primary)
                        .descriptionTextColorInt(secondary)
                        .targetCircleColorInt(primary)
                        .drawShadow(Preferences.get(context).isTapIntroShadowEnabled());

                if (title != null) {
                    tapTarget.textTypeface(title);
                }

                //if (description != null) {
                //tapTarget.descriptionTypeface(description);
                //}

                TapTargetView.showFor(activity, tapTarget,
                        new TapTargetView.Listener() {

                            @Override
                            public void onTargetDismissed(TapTargetView view, boolean userInitiated) {
                                super.onTargetDismissed(view, userInitiated);
                                Preferences.get(context).setTimeToShowIconsIntro(false);
                            }
                        });
            } catch (Exception e) {
                LogUtil.e(Log.getStackTraceString(e));
            }
        }, 100);
    }
}
 
Example 19
Source File: VerticalWeekCalendar.java    From VerticalCalendar with Apache License 2.0 4 votes vote down vote up
public VerticalWeekCalendar init(AppCompatActivity appCompatActivity){

            VerticalWeekCalendar calendar = appCompatActivity.findViewById(view);
            calendar.init();
            return calendar;
        }