Posts

A Simple SwiftUI animation

Image
struct ContentView: View {         @State private var animationAmount: CGFloat = 1             var body: some View {         Button("Tap Me") {         }         .padding(40)         .background(Color.red)         .foregroundColor(Color.white)         .clipShape(Circle())         .overlay(             Circle()                 .stroke(Color.red)                 .scaleEffect(animationAmount)                 .opacity(Double(2 - animationAmount))                 .animation(                     Animation.easeOut(duration: 1)                     .repeatForever(autoreverses: false)             )         )         .onAppear {                 self.animationAmount = 2         }     } } Credits: https://www.hackingwithswift.com/books/ios-swiftui/customizing-animations-in-swiftui

Dagger 03: Injecting via an AppModule using @Provides and @Inject

1. Create a class AppModule to inject stuff at the Application level. Add the AppModule in the modules section. Do not forget. @Module public class AppModule { } 2. In this class you can inject stuff like Retrofit instance or Glide Instance or a Constant class instance into your Activities by using @Provides . To Inject a String that represents a value, add the following code into the AppModule class    @Provides     static String someString() {         return "This is a test string";     } 3. To use these values inside your Activity using @Inject annotation in front the properties into which you wanna inject these values.      private static final String TAG = "AuthActivity";          @Inject     String injectedString;     @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_auth);         Log.d(TAG, "onCreate: " + injectedString)

Dagger02: Inject Activities with @ContributesAndroidInjector

Components acts as Services . Activities/Fragments acts as Clients . Dagger Module: They are a place for dependencies to live so that we can add them to the components. 1. Create a ActivityBuildersModule class. This is the class where the DI of the Activity we want would happen. In this case it is AuthActivity . import dagger.Module; import dagger.android.ContributesAndroidInjector; @Module public abstract class ActivityBuildersModule {     @ContributesAndroidInjector     abstract AuthActivity contributeAuthActivity(); } 2. Add this module into the AppComponent class module section. @Component(         modules = {                 AndroidSupportInjectionModule.class,                 ActivityBuildersModule.class         } ) Now we can basically inject stuff into the AuthActivity . 3. Change the Activity to extend from DaggerCompatActivity .

Dagger01: Setting up

1. Install the Dagger Dependencies. def DAGGER_VERSION = "2.22" implementation "com.google.dagger:dagger:$DAGGER_VERSION" annotationProcessor "com.google.dagger:dagger-compiler:$DAGGER_VERSION" implementation "com.google.dagger:dagger-android:$DAGGER_VERSION" implementation "com.google.dagger:dagger-android-support:$DAGGER_VERSION" annotationProcessor "com.google.dagger:dagger-android-processor:$DAGGER_VERSION" 2. Create a BaseApplication class that extends DaggerApplication import dagger.android.AndroidInjector; import dagger.android.support.DaggerApplication; public class BaseApplication extends DaggerApplication {     @Override     protected AndroidInjector<? extends DaggerApplication> applicationInjector() {         return null;     } } 3. Add the BaseApplication class to the Manifest file.  <application         android:allowBackup="true"         android:name=".

Reading local files in an iOS Project

Reading String content from a Bundle

Concurrency in iOS - 1: Introduction to Grand Central Dispatch and Operations

In this blog series, I will try to simplify the concept of Concurrency in iOS using the Swift programming language. I myself have struggled with it for a long period of time and in the recent past started putting more effort into understanding it and implemented it certain apps successfully.  This whole series will evolve both as tutorial series with explanations of various important concepts with practical examples and a cookbook kind of recipes that you can pick up quickly in your iOS projects. Hope you find the series useful and without wasting any time lets get some concepts cleared out of the way. In iOS development ecosystem, there are majorly 2 ways to handle threads.  1. Grand Central Dispatch: For one time tasks we do not need to manage the state. 2. Operations: For reusable tasks that need to be performed multiple times. Grand Central Dispatch (referred as GCD) GCD is the implementation of C's libdispatch library which is used to queue up tasks and run them

What happened to the blog ?

Its almost more than a year that I have blogged at all. In the mean time I created another blog which I am thinking not to use right now but the future of this blog is in my hands. As 2015 ends I will be trying to right more blogs next year on different topics including iOS, Android, .NET and some front end development. I will start posting some articles on Data Structures and Algorithms which I think will remain my main focus as I am starting to prepare for interviews. Though the New Years hasn't started but I know my resolution for next will be to get a job as a Software Engineer in a renowned company in U.S.A. mostly as a Android development. I will putting a lot of my free time in improving my health and preparing for interviews and learning more and more Android development. My initial thought was to go for 1 course a month target as I have bought many many courses on Udemy so I thought I will try to finish one course every month but that way I will be focussing to much on

Playing with Swift.

Image
Finally Udacity lauched there iOS Development course with Swift. I started the course. Its been just few hours that I say the launch of the course on their website I have already completed 4 Units out 6 units from the course. I must say I have learnt alot.

A Simple Script to remove all numbers from file names and renaming them

#Script to remove numbers from file names and rename them import os import string def renameFiles():     files_list = os.listdir(r'/home/jayc/Python/prank/')     print(files_list)     saved_path = os.getcwd()     os.chdir(r'/home/jayc/Python/prank/')     print(os.getcwd())     for file_name in files_list:         os.rename(file_name, file_name.translate(file_name.maketrans('0123456789', '          ')))     os.chdir(saved_path) renameFiles()

A Simple Script to open a browser every two hours

#Script to open youtube after every 2hours import webbrowser import time total_breaks = 3 break_counter = 1 while(break_counter <= total_breaks):     time.sleep(2*60*60)     webbrowser.open("http://www.youtube.com")     break_counter = break_counter+1