Compulsory Imprint library
android {
compileSdk 32
defaultConfig {
applicationId "com.dj.wedme"
useLibrary 'org.apache.http.legacy'
minSdk 23
targetSdk 32
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
dataBinding {
enabled = true
}
viewBinding {
enabled = true
}
buildFeatures {
viewBinding true
}
}
dependency
dependencies :-
implementation 'com.intuit.sdp:sdp-android:1.0.6'
implementation 'com.intuit.ssp:ssp-android:1.0.6'
implementation 'com.airbnb.android:lottie:3.7.1'
implementation 'com.github.bumptech.glide:glide:4.13.2'
annotationProcessor 'com.github.bumptech.glide:compiler:4.13.0'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'com.google.code.gson:gson:2.9.1'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
// implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.multidex:multidex:2.0.1'
.
MultiDex Application
public class App extends MultiDexApplication {
private static App instance;
private static App mInstance;
public App() {
mInstance = this;
}
public static Context applicationContext() {
return instance.getApplicationContext();
}
public static synchronized App getInstance() {
App myApplication;
synchronized (App.class) {
synchronized (App.class) {
myApplication = mInstance;
}
}
return myApplication;
}
public void attachBaseContext(Context context) {
super.attachBaseContext(context);
instance = this;
}
public static String path;
public void onCreate() {
super.onCreate();
mInstance = this;
MultiDex.install(this);
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().build());
}
}
MenifestFile
<application
android:name=".App"
android:allowBackup="true"
android:appComponentFactory="androidx.core.app.CoreComponentFactory"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:preserveLegacyExternalStorage="true"
android:requestLegacyExternalStorage="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
Theam
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
<item name="colorAccent">@color/colorAccent</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="android:fontFamily">@font/qr</item>
<!-- <item name="android:statusBarColor" tools:targetApi="l">@color/statusBarColor</item>-->
<item name="android:windowAnimationStyle">@style/MyCustomActivityAnimation</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<!-- <item name="android:statusBarColor">@color/statuscolor</item>-->
</style>
Retrofit Conectivity
public class APIClient {
public static String BASE_URL = "https://imagixcodders.com/Wedme/Api/";
private static Retrofit retrofit = null;
private static final Object LOCK = new Object();
public static Retrofit getClient() {
synchronized (LOCK) {
if (retrofit == null) {
Gson gson = new GsonBuilder()
.setLenient()
.create();
OkHttpClient okHttpClient = new OkHttpClient().newBuilder()
.connectTimeout(40, TimeUnit.SECONDS)
.readTimeout(60, TimeUnit.SECONDS)
.writeTimeout(60, TimeUnit.SECONDS)
.build();
retrofit = new Retrofit.Builder()
.client(okHttpClient)
.baseUrl(BASE_URL)
// .addConverterFactory(GsonConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create(gson))
.build();
}
return retrofit;
}
}
}
afrter imfor interface
public interface ApiInterface {
@FormUrlEncoded
@POST("Login")
Call<LoginModel> getLogin(
@Field("mobile") String mobile,
@Field("password") String password);
@GET("Band_Party_List")
Call<HomeBandPartyListModel> getHomeBandPartyList();
@Multipart
@POST("Profile_Update")
Call<UpdateProfileModel> upDateUser(
@Part("user_id") RequestBody user_id,
@Part("first_name") RequestBody first_name,
@Part("last_name") RequestBody last_name,
@Part("mobile") RequestBody mobile,
@Part("email") RequestBody email,
@Part MultipartBody.Part post_photo);
}
call Post method
call get method
ApiInterface apiInterface = APIClient.getClient().create(ApiInterface.class);
Call<TodaySliderImagesModel> call = apiInterface.getTodaySliderImageList();
Rohit.LOG(TAG, "getTodaySliderImageList list url " + call.request());
call.enqueue(new Callback<TodaySliderImagesModel>() {
@Override
public void onResponse(Call<TodaySliderImagesModel> call, Response<TodaySliderImagesModel> response) {
// Rohit.LOG(TAG, "getSearchShopList list response " + response.body().msg);
if (!response.isSuccessful()) {
Toast.makeText(context, "Contact Admin", Toast.LENGTH_SHORT).show();
callApi.onFailed("getBrokerList list error ");
} else {
TodaySliderImagesModel model = response.body();
if (model.status.equalsIgnoreCase("200")) {
liveBrokerList.setValue(model.slider_data);
callApi.onSuccessResponse(model.msg);
Rohit.LOG(TAG, "Total getBrokerList :-" + String.valueOf(model.slider_data.size()));
} else {
callApi.onFailed( response.body().msg);
}
}
}
@Override
public void onFailure(Call<TodaySliderImagesModel> call, Throwable t) {
callApi.onFailed("getBrokerList list error " + t.getMessage());
Rohit.LOG(TAG, "getBrokerList list error " + t.getMessage());
}
});
0 Comments
Post a Comment