Skip to content

Commit cb142db

Browse files
author
karan.m
committed
Added Utils and update code
1 parent 9dd8100 commit cb142db

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1265
-521
lines changed

.idea/gradle.xml

-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

-9
This file was deleted.

.idea/vcs.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+16-14
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
# Android_Kickstart
2-
The goal of this project is to help you in your development.
2+
The goal of this project is to help Developers in development.
33

44
## Activity
5-
* BaseActivity to use as parent activity
5+
* activities/BaseActivity.java to use as parent activity
66

77
## Fragment
8-
* BaseFrament to use as parent fragment
8+
* fragments/BaseFrament.java to use as parent fragment
99

1010
## Dialog
11-
* MyProgressDialog to show progress bind with BaseActivity and BaseFragment
11+
* dialogs/CustomProgressDialog.java to show progress bind with BaseActivity and BaseFragment
1212

1313
## Utility
14-
* BitmapUtil
15-
* CommonUtil
16-
* DateUtil
17-
* DialogUtil
18-
* EncriptionUtil
19-
* LogUtil
20-
* NetorkUtil
21-
* PreferenceUtil
22-
* ValidationUtil
23-
* ViewUtil
14+
* utils/BitmapUtil.java
15+
* utils/CaptchUtil.java
16+
* utils/CommonUtil.java
17+
* utils/DateUtil.java
18+
* utils/DialogUtil.java
19+
* utils/EncriptionUtil.java
20+
* utils/IntentUtils.java
21+
* utils/LogUtil.java
22+
* utils/NetorkUtil.java
23+
* utils/PreferenceUtil.java
24+
* utils/ValidationUtil.java
25+
* utils/ViewUtil.java

app/build.gradle

+14-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 26
4+
compileSdkVersion 25
5+
buildToolsVersion "25.0.3"
56
defaultConfig {
67
applicationId "com.android.kickstart"
7-
minSdkVersion 19
8-
targetSdkVersion 26
8+
minSdkVersion 15
9+
targetSdkVersion 25
910
versionCode 1
1011
versionName "1.0"
1112
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@@ -18,8 +19,15 @@ android {
1819
}
1920
}
2021

22+
ext {
23+
supportLibraryVersion = '25.3.1'
24+
}
25+
26+
2127
dependencies {
22-
implementation fileTree(dir: 'libs', include: ['*.jar'])
23-
implementation 'com.android.support:appcompat-v7:26.1.0'
24-
implementation 'com.android.support:design:26.1.0'
28+
compile fileTree(dir: 'libs', include: ['*.jar'])
29+
compile "com.android.support:appcompat-v7:$supportLibraryVersion"
30+
compile "com.android.support:design:$supportLibraryVersion"
31+
32+
compile 'com.android.support.constraint:constraint-layout:1.0.2'
2533
}

app/src/main/AndroidManifest.xml

+5-2
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,19 @@
1414
android:roundIcon="@mipmap/ic_launcher_round"
1515
android:supportsRtl="true"
1616
android:theme="@style/AppTheme">
17+
1718
<activity
18-
android:name="com.android.kickstart.activity.MainActivity"
19-
android:label="@string/app_name"
19+
android:name=".activities.MainActivity"
20+
android:label="@string/title_activity_main"
2021
android:theme="@style/AppTheme.NoActionBar">
22+
2123
<intent-filter>
2224
<action android:name="android.intent.action.MAIN" />
2325

2426
<category android:name="android.intent.category.LAUNCHER" />
2527
</intent-filter>
2628
</activity>
29+
2730
</application>
2831

2932
</manifest>

app/src/main/java/com/android/kickstart/activity/BaseActivity.java renamed to app/src/main/java/com/android/kickstart/activities/BaseActivity.java

+66-61
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.android.kickstart.activity;
1+
package com.android.kickstart.activities;
22

33
import android.app.Fragment;
44
import android.app.FragmentManager;
@@ -12,8 +12,9 @@
1212
import android.view.inputmethod.InputMethodManager;
1313

1414
import com.android.kickstart.R;
15-
import com.android.kickstart.dialog.MyProgressDialog;
16-
import com.android.kickstart.utility.PreferenceUtil;
15+
import com.android.kickstart.dialogs.CustomProgressDialog;
16+
import com.android.kickstart.utils.PreferenceUtil;
17+
1718

1819
public abstract class BaseActivity extends AppCompatActivity implements View.OnClickListener {
1920

@@ -24,7 +25,15 @@ public abstract class BaseActivity extends AppCompatActivity implements View.OnC
2425
* lastClickedTime contains last clicked time of view
2526
*/
2627
public static final long MAX_CLICK_INTERVAL = 1000;
28+
/*
29+
* SharedPreferences
30+
*/
31+
public PreferenceUtil mPreferenceUtil;
2732
protected long lastClickedTime = 0;
33+
/*
34+
* ProgressDialog
35+
*/
36+
private CustomProgressDialog progressDialog;
2837

2938
/*
3039
* abstract method for set view
@@ -37,23 +46,14 @@ public abstract class BaseActivity extends AppCompatActivity implements View.OnC
3746
*/
3847
public abstract void initializeComponents();
3948

40-
/*
41-
* ProgressDialog
42-
*/
43-
private MyProgressDialog progressDialog;
44-
45-
/*
46-
* SharedPreferences
47-
*/
48-
private PreferenceUtil mPreferenceUtil;
4949

5050
@Override
5151
protected void onCreate(Bundle savedInstanceState) {
5252
super.onCreate(savedInstanceState);
5353
setContentView(getActivityView());
5454

5555
// Initialize preference utility
56-
mPreferenceUtil = new PreferenceUtil(getApplicationContext(),getString(R.string.app_name));
56+
mPreferenceUtil = new PreferenceUtil(getApplicationContext(), getString(R.string.app_name));
5757

5858
initializeComponents();
5959
}
@@ -78,59 +78,60 @@ public void onClick(View view) {
7878
}
7979
lastClickedTime = SystemClock.elapsedRealtime();
8080

81+
8182
}
8283

83-
/*
84-
* @param intent
84+
/**
85+
* @param className Name of the next Activity (NextActivity.class)
8586
*/
86-
public void navigateActivity(Intent intent) {
87-
startActivity(intent);
87+
public void startActivity(Class<?> className) {
88+
startActivity(new Intent(getApplicationContext(), className));
8889
}
8990

90-
/*
91-
* @param intent
92-
* @param enterAnim
93-
* @param exitAnim
91+
/**
92+
* @param className Name of the next Activity (NextActivity.class)
93+
* @param resultCode Activity result code
9494
*/
95-
public void navigateActivity(Intent intent, int enterAnim, int exitAnim) {
96-
startActivity(intent);
97-
overridePendingTransition(enterAnim, exitAnim);
95+
public void startActivity(Class<?> className, int resultCode) {
96+
startActivityForResult(new Intent(getApplicationContext(), className), resultCode);
9897
}
9998

100-
/*
101-
* @param intent
102-
* @param resultCode
99+
/**
100+
* @param intent Activity Intent
101+
* @param resultCode Activity result code
103102
*/
104-
public void navigateActivityForResult(Intent intent, int resultCode) {
105-
startActivityForResult(intent, resultCode);
103+
public void startActivityForResultBack(Intent intent, int resultCode) {
104+
setResult(resultCode, intent);
106105
}
107106

108-
/*
109-
* @param intent
110-
* @param resultCode
111-
* @param enterAnim
112-
* @param exitAnim
107+
/**
108+
* @param className Name of the next Activity (NextActivity.class)
109+
* @param enterAnim enter animation
110+
* @param exitAnim exit animation
113111
*/
114-
public void navigateActivityForResult(Intent intent, int resultCode, int enterAnim, int exitAnim) {
115-
startActivityForResult(intent, resultCode);
112+
public void startActivity(Class<?> className, int enterAnim, int exitAnim) {
113+
startActivity(new Intent(getApplicationContext(), className));
116114
overridePendingTransition(enterAnim, exitAnim);
117115
}
118116

119-
/*
120-
* @param intent
121-
* @param resultCode
117+
/**
118+
* @param className Name of the next Activity (NextActivity.class)
119+
* @param resultCode Activity result code
120+
* @param enterAnim enter animation
121+
* @param exitAnim exit animation
122122
*/
123-
public void navigateActivityForResultBack(Intent intent, int resultCode) {
124-
setResult(resultCode, intent);
123+
public void startActivity(Class<?> className, int resultCode, int enterAnim, int exitAnim) {
124+
startActivityForResult(new Intent(getApplicationContext(), className), resultCode);
125+
overridePendingTransition(enterAnim, exitAnim);
125126
}
126127

127-
/*
128-
* @param intent
129-
* @param resultCode
130-
* @param enterAnim
131-
* @param exitAnim
128+
/**
129+
* @param intent Activity Intent
130+
* @param resultCode Activity result code
131+
* @param enterAnim enter animation
132+
* @param exitAnim exit animation
132133
*/
133-
public void navigateActivityForResultBack(Intent intent, int resultCode, int enterAnim, int exitAnim) {
134+
public void startActivityForResultBack(Intent intent, int resultCode, int enterAnim, int exitAnim) {
134135
setResult(resultCode, intent);
135136
overridePendingTransition(enterAnim, exitAnim);
136137
}
@@ -143,16 +144,15 @@ public void navigateActivityForResultBack(Intent intent, int resultCode, int ent
143144
* @param nextFragment New Fragment to be loaded into fragmentContainerResourceId
144145
* @param requiredAnimation true if screen transition animation is required
145146
* @param commitAllowingStateLoss true if commitAllowingStateLoss is needed
146-
* @return true if new Fragment added successfully into container, false otherwise
147-
* @throws IllegalStateException Exception if Fragment transaction is invalid
147+
* @return true if new Fragment added successfully into container, false otherwise
148148
*/
149-
public boolean addFragment(final int fragmentContainerResourceId, final Fragment currentFragment, final Fragment nextFragment, final boolean requiredAnimation, final boolean commitAllowingStateLoss) {
149+
public boolean addFragment(int fragmentContainerResourceId, Fragment currentFragment, Fragment nextFragment, boolean requiredAnimation, boolean commitAllowingStateLoss) {
150150
try {
151151
if (currentFragment == null || nextFragment == null) {
152152
return false;
153153
}
154-
final FragmentManager fragmentManager = getFragmentManager();
155-
final FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
154+
FragmentManager fragmentManager = getFragmentManager();
155+
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
156156

157157
if (requiredAnimation) {
158158
fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_NONE);
@@ -161,7 +161,7 @@ public boolean addFragment(final int fragmentContainerResourceId, final Fragment
161161
fragmentTransaction.add(fragmentContainerResourceId, nextFragment, nextFragment.getClass().getSimpleName());
162162
fragmentTransaction.addToBackStack(nextFragment.getClass().getSimpleName());
163163

164-
final Fragment parentFragment;
164+
Fragment parentFragment;
165165
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
166166
parentFragment = currentFragment.getParentFragment();
167167
if (parentFragment == null) {
@@ -176,7 +176,6 @@ public boolean addFragment(final int fragmentContainerResourceId, final Fragment
176176
} else {
177177
fragmentTransaction.commitAllowingStateLoss();
178178
}
179-
180179
return true;
181180
} catch (IllegalStateException e) {
182181
e.printStackTrace();
@@ -193,14 +192,14 @@ public boolean addFragment(final int fragmentContainerResourceId, final Fragment
193192
* @param nextFragment New Fragment to be loaded into fragmentContainerResourceId
194193
* @param requiredAnimation true if screen transition animation is required
195194
* @param commitAllowingStateLoss true if commitAllowingStateLoss is needed
196-
* @return true if new Fragment added successfully into container, false otherwise
195+
* @return true if new Fragment added successfully into container, false otherwise
197196
*/
198-
public boolean replaceFragment(final int fragmentContainerResourceId, final FragmentManager fragmentManager, final Fragment nextFragment, final boolean requiredAnimation, final boolean commitAllowingStateLoss) {
197+
public boolean replaceFragment(int fragmentContainerResourceId, FragmentManager fragmentManager, Fragment nextFragment, boolean requiredAnimation, boolean commitAllowingStateLoss) {
199198
try {
200199
if (nextFragment == null || fragmentManager == null) {
201200
return false;
202201
}
203-
final FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
202+
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
204203
if (requiredAnimation) {
205204
fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_NONE);
206205
}
@@ -211,21 +210,27 @@ public boolean replaceFragment(final int fragmentContainerResourceId, final Frag
211210
} else {
212211
fragmentTransaction.commitAllowingStateLoss();
213212
}
214-
215213
return true;
216214
} catch (IllegalStateException e) {
217215
e.printStackTrace();
218216
}
219217
return false;
220218
}
221219

222-
private void displayDialog(String message,boolean isCancelable) {
223-
progressDialog = new MyProgressDialog(this,message, isCancelable);
220+
/**
221+
* @param message ProgressDialog message
222+
* @param isCancelable true if user need to cancel dialog on touch else false
223+
*/
224+
private void displayDialog(String message, boolean isCancelable) {
225+
progressDialog = new CustomProgressDialog(this, message, isCancelable);
224226
if (!isFinishing()) {
225227
progressDialog.show();
226228
}
227229
}
228230

231+
/**
232+
*
233+
*/
229234
private void dismissDialog() {
230235
if (progressDialog != null && progressDialog.isShowing())
231236
progressDialog.dismiss();
@@ -246,4 +251,4 @@ protected void onDestroy() {
246251
if (progressDialog != null && progressDialog.isShowing())
247252
dismissDialog();
248253
}
249-
}
254+
}

0 commit comments

Comments
 (0)