Posts

Showing posts from August, 2017

Dependence injection at fragment using dagger

Step 1 :  Add to activity module @Subcomponent (modules = {ActivityModule. class }) public interface FragmentComponent { void inject(HamburgerActivity mainActivity); void inject(HomeScreenFragment homeScreenFragment); } Step 2: inject current fragment in onViewCreated @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { return inflater.inflate(R.layout. com_philips_lumea_treatment_done , null ); } @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super .onViewCreated(view, savedInstanceState); // inject current fragment ((Application) getActivity().getApplication()).getFragmentComponent().inject( this ); } Step 3 : Register and Unregister @Override public void onStop() { super .onStop(); if ( eventing != null ) { eventing .unregister( this ); } } @Override public void onStart() { super .onStart(); if

How to exclude internal library dependency and adding .arr file of the same library Or enforcing library to use by your app

configurations {     compile.exclude module: 'commons'     all*.exclude group: 'com.philips.platform.appinfra', module: 'reports' } compile(name:'AppInfra-1.7.0', ext:'aar');      //UIKIT LIBRARY      compile(group: 'com.philips.cdp', name: 'uikitLib', version: "${uikitVersion}", ext: 'aar') {          exclude group: 'com.android.support'         transitive = true         exclude module: 'shared'        transitive = true      }      //REGISTRATION LIBRARY      compile(group: 'com.philips.cdp', name: 'registrationApi', version: "${registrationVer}", ext: 'aar') {          exclude group: 'com.android.support'         exclude group: 'com.google.android', module: 'android'         exclude module: 'AppInfra'          transitive = true      }

Gradle commands

./gradlew --refresh-dependencies ./gradlew clean createDebugCoverageReport jacocoTestReport  ./gradlew cC ./gradlew clean createDebugCoverageReport jacocoTestReport Release ./gradlew clean assembleRelease Debug   ./gradlew clean assembleDebug   cC TICS ./gradlew --no-daemon clean assembleDebug jacocoTestReport

How to calculate time complexity between code

            long t1 = System.nanoTime();             long t2 = System.nanoTime();             Log.v("","Time difference : "+(t2 - t1));             Log.v("","Total time takes : "+(t2 - t1) * 1e-9);