Closed ghost closed 5 years ago
my error:
02-16 20:57:41.935 7975-7975/com.example.jeeev.tma E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.jeeev.tma, PID: 7975
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.jeeev.tma/com.example.jeeev.tma.io.github.project_travel_mate.MainActivity}: android.view.InflateException: Binary XML file line #38: Binary XML file line #38: Error inflating class android.support.design.widget.NavigationView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2452)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2535)
at android.app.ActivityThread.access$900(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1380)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:152)
at android.app.ActivityThread.main(ActivityThread.java:5497)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: android.view.InflateException: Binary XML file line #38: Binary XML file line #38: Error inflating class android.support.design.widget.NavigationView
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.example.jeeev.tma.io.github.project_travel_mate.MainActivity.onCreate(MainActivity.java:100)
at android.app.Activity.performCreate(Activity.java:6289)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2405)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2535)
at android.app.ActivityThread.access$900(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1380)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:152)
at android.app.ActivityThread.main(ActivityThread.java:5497)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: android.view.InflateException: Binary XML file line #38: Error inflating class android.support.design.widget.NavigationView
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.example.jeeev.tma.io.github.project_travel_mate.MainActivity.onCreate(MainActivity.java:100)
at android.app.Activity.performCreate(Activity.java:6289)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2405)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2535)
at android.app.ActivityThread.access$900(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1380)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:152)
at android.app.ActivityThread.main(ActivityThread.java:5497)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.example.jeeev.tma.io.github.project_travel_mate.MainActivity.onCreate(MainActivity.java:100)
at android.app.Activity.performCreate(Activity.java:6289)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2405)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2535)
at android.app.ActivityThread.access$900(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1380)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:152)
at android.app.ActivityThread.main(ActivityThread.java:5497)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: android.view.InflateException: Binary XML file line #14: Binary XML file line #14: Error inflating class utils.CircleImageView
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.support.design.internal.NavigationMenuPresenter.inflateHeaderView(NavigationMenuPresenter.java:207)
at android.support.design.widget.NavigationView.inflateHeaderView(NavigationView.java:281)
at android.support.design.widget.NavigationView.
Didn't find class "utils.CircleImageView"
this is the error
Also, why have you copy pasted the whole code for main activity and gradle? Isnt it already here on repo? Or, if you made some changes, why dont you just write the change you made
Didn't find class "utils.CircleImageView"
this is the errorAlso, why have you copy pasted the whole code for main activity and gradle? Isnt it already here on repo? Or, if you made some changes, why dont you just write the change you made
added in gradle file: implementation 'de.hdodenhof:circleimageview:2.0.0'
my error:
02-16 20:57:41.935 7975-7975/com.example.jeeev.tma E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.jeeev.tma, PID: 7975 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.jeeev.tma/com.example.jeeev.tma.io.github.project_travel_mate.MainActivity}: android.view.InflateException: Binary XML file line #38: Binary XML file line #38: Error inflating class android.support.design.widget.NavigationView at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2452) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2535) at android.app.ActivityThread.access$900(ActivityThread.java:155) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1380) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:152) at android.app.ActivityThread.main(ActivityThread.java:5497) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: android.view.InflateException: Binary XML file line #38: Binary XML file line #38: Error inflating class android.support.design.widget.NavigationView at android.view.LayoutInflater.inflate(LayoutInflater.java:539) at android.view.LayoutInflater.inflate(LayoutInflater.java:423) at android.view.LayoutInflater.inflate(LayoutInflater.java:374) at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) at com.example.jeeev.tma.io.github.project_travel_mate.MainActivity.onCreate(MainActivity.java:100) at android.app.Activity.performCreate(Activity.java:6289) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2405) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2535) at android.app.ActivityThread.access$900(ActivityThread.java:155) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1380) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:152) at android.app.ActivityThread.main(ActivityThread.java:5497) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: android.view.InflateException: Binary XML file line #38: Error inflating class android.support.design.widget.NavigationView at android.view.LayoutInflater.createView(LayoutInflater.java:645) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) at android.view.LayoutInflater.inflate(LayoutInflater.java:515) at android.view.LayoutInflater.inflate(LayoutInflater.java:423) at android.view.LayoutInflater.inflate(LayoutInflater.java:374) at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) at com.example.jeeev.tma.io.github.project_travel_mate.MainActivity.onCreate(MainActivity.java:100) at android.app.Activity.performCreate(Activity.java:6289) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2405) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2535) at android.app.ActivityThread.access$900(ActivityThread.java:155) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1380) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:152) at android.app.ActivityThread.main(ActivityThread.java:5497) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance(Native Method) at android.view.LayoutInflater.createView(LayoutInflater.java:619) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) at android.view.LayoutInflater.inflate(LayoutInflater.java:515) at android.view.LayoutInflater.inflate(LayoutInflater.java:423) at android.view.LayoutInflater.inflate(LayoutInflater.java:374) at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) at com.example.jeeev.tma.io.github.project_travel_mate.MainActivity.onCreate(MainActivity.java:100) at android.app.Activity.performCreate(Activity.java:6289) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2405) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2535) at android.app.ActivityThread.access$900(ActivityThread.java:155) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1380) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:152) at android.app.ActivityThread.main(ActivityThread.java:5497) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: android.view.InflateException: Binary XML file line #14: Binary XML file line #14: Error inflating class utils.CircleImageView at android.view.LayoutInflater.inflate(LayoutInflater.java:539) at android.view.LayoutInflater.inflate(LayoutInflater.java:423) at android.support.design.internal.NavigationMenuPresenter.inflateHeaderView(NavigationMenuPresenter.java:207) at android.support.design.widget.NavigationView.inflateHeaderView(NavigationView.java:281) at android.support.design.widget.NavigationView.(NavigationView.java:193) at android.support.design.widget.NavigationView.(NavigationView.java:104) at java.lang.reflect.Constructor.newInstance(Native Method) at android.view.LayoutInflater.createView(LayoutInflater.java:619) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) at android.view.LayoutInflater.inflate(LayoutInflater.java:515) at android.view.LayoutInflater.inflate(LayoutInflater.java:423) at android.view.LayoutInflater.inflate(LayoutInflater.java:374) at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) at com.example.jeeev.tma.io.github.project_travel_mate.MainActivity.onCreate(MainActivity.java:100) at android.app.Activity.performCreate(Activity.java:6289) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2405) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2535) at android.app.ActivityThread.access$900(ActivityThread.java:155) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1380) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:152) at android.app.ActivityThread.main(ActivityThread.java:5497) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: android.view.InflateException: Binary XML file line #14: Error inflating class utils.CircleImageView at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) at android.view.LayoutInflater.inflate(LayoutInflater.java:515) at android.view.LayoutInflater.inflate(LayoutInflater.java:423) at android.support.design.internal.NavigationMenuPresenter.inflateHeaderView(NavigationMenuPresenter.java:207) at android.support.design.widget.NavigationView.inflateHeaderView(NavigationView.java:281) at android.support.design.widget.NavigationView.(NavigationView.java:193) at android.support.design.widget.NavigationView.(NavigationView.java:104) at java.lang.reflect.Constructor.newInstance(Native Method) at android.view.LayoutInflater.createView(LayoutInflater.java:619) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) at android.view.LayoutInflater.inflate(LayoutInflater.java:515) at android.view.LayoutInflater.inflate(LayoutInflater.java:423) at android.view.LayoutInflater.inflate(LayoutInflater.java:374) at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) at com.example.jeeev.tma.io.github.project_travel_mate.MainActivity.onCreate(MainActivity.java:100) at android.app.Activity.performCreate(Activity.java:6289) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2405) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2535) at android.app.ActivityThread.access$900(ActivityThread.java:155) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1380) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:152) at android.app.ActivityThread.main(ActivityThread.java:5497) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: java.lang.ClassNotFoundException: Didn't find class "utils.CircleImageView" on path: DexPathList[[zip file "/data/app/com.example.jeeev.tma-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.jeeev.tma-1/lib/arm64, /vendor/lib64, /system/lib64
when i run the application got this error?
Why did you add this? added in gradle file: implementation 'de.hdodenhof:circleimageview:2.0.0' We already have circle imageview implementation
I hope you followed these steps: https://github.com/project-travel-mate/Travel-Mate/wiki#installation There shouldnt be this error.
It's working now Thanks! you can close this
Describe your issue here. after login app crashes on home page ie., mainactivity.java app.gradle file apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { compileSdkVersion 28 defaultConfig { applicationId "com.example.jeeev.tma" minSdkVersion 23 targetSdkVersion 23 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" multiDexEnabled true }
}
dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') //implementation 'com.google.android.gms:play-services-vision:YOUR_PLAYSERVICES_VERSION' //noinspection GradleCompatible implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support:support-compat:28.0.0' testImplementation 'junit:junit:4.12' //implementation 'android.support.design:design:23.0.1@aar' implementation 'com.android.support:design:28.0.0' //noinspection GradleCompatible implementation "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion" implementation 'com.android.support:appcompat-v7:28.0.0' //noinspection GradleCompatible implementation "com.android.support:support-v4:$rootProject.supportLibraryVersion" implementation 'com.android.support.constraint:constraint-layout:1.1.3' androidTestImplementation 'com.android.support.test:runner:1.0.2' implementation 'com.android.support:recyclerview-v7:28.0.0' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' implementation 'com.squareup.okhttp3:okhttp:3.10.0' implementation 'com.android.support:recyclerview-v7:28.0.0'
}
project **gradle:
** buildscript { ext { kotlin_version = '1.2.71' } repositories { jcenter() google() } repositories { flatDir { dirs 'libs' } } dependencies { classpath 'com.android.tools.build:gradle:3.2.1'}
allprojects { repositories { google() jcenter() maven { url "https://jitpack.io" } } }
task clean(type: Delete) { delete rootProject.buildDir }
ext { supportLibraryVersion= '27.1.0' } mainactivity package com.example.jeeev.tma.io.github.project_travel_mate;
import android.Manifest; import android.app.AlertDialog; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.support.v4.app.Fragment; import android.os.Looper; import android.preference.PreferenceManager; import android.support.annotation.NonNull; import android.support.design.widget.NavigationView; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.content.ContextCompat; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.AppCompatActivity; import android.support.v7.view.ContextThemeWrapper; import android.support.v7.widget.Toolbar; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.ImageView; import android.widget.TextView;
import com.github.juanlabrador.badgecounter.BadgeCounter; import com.squareup.picasso.Picasso;
import org.json.JSONException; import org.json.JSONObject;
import java.io.IOException; import java.util.Objects; import com.example.jeeev.tma.io.github.project_travel_mate.R; import butterknife.ButterKnife; import com.example.jeeev.tma.io.github.project_travel_mate.destinations.CityFragment; import com.example.jeeev.tma.io.github.project_travel_mate.friend.FriendsProfileActivity; import com.example.jeeev.tma.io.github.project_travel_mate.friend.MyFriendsFragment; import com.example.jeeev.tma.io.github.project_travel_mate.login.LoginActivity; import com.example.jeeev.tma.io.github.project_travel_mate.mytrips.MyTripInfoActivity; import com.example.jeeev.tma.io.github.project_travel_mate.mytrips.MyTripsFragment; import com.example.jeeev.tma.io.github.project_travel_mate.notifications.NotificationsActivity; import com.example.jeeev.tma.io.github.project_travel_mate.travel.TravelFragment; import com.example.jeeev.tma.io.github.project_travel_mate.utilities.AboutUsFragment; import com.example.jeeev.tma.io.github.project_travel_mate.utilities.UtilitiesFragment; import io.github.tonnyl.whatsnew.WhatsNew; import io.github.tonnyl.whatsnew.item.WhatsNewItem; import com.example.jeeev.tma.objects.Trip; import okhttp3.Call; import okhttp3.Callback; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import com.example.jeeev.tma.utils.DailyQuotesManager;
import static com.example.jeeev.tma.utils.Constants.API_LINK_V2; import static com.example.jeeev.tma.utils.Constants.AUTHORIZATION; import static com.example.jeeev.tma.utils.Constants.SHARE_PROFILE_USER_ID_QUERY; import static com.example.jeeev.tma.utils.Constants.SHARE_TRIP_TRIP_ID_QUERY; import static com.example.jeeev.tma.utils.Constants.USER_DATE_JOINED; import static com.example.jeeev.tma.utils.Constants.USER_EMAIL; import static com.example.jeeev.tma.utils.Constants.USER_ID; import static com.example.jeeev.tma.utils.Constants.USER_IMAGE; import static com.example.jeeev.tma.utils.Constants.USER_NAME; import static com.example.jeeev.tma.utils.Constants.USER_STATUS; import static com.example.jeeev.tma.utils.Constants.USER_TOKEN; import static com.example.jeeev.tma.utils.DateUtils.getDate; import static com.example.jeeev.tma.utils.DateUtils.rfc3339ToMills; import static com.example.jeeev.tma.utils.WhatsNewStrings.WHATS_NEW1_TEXT; import static com.example.jeeev.tma.utils.WhatsNewStrings.WHATS_NEW1_TITLE;
/**
Launcher Activity; Handles fragment changes; */ public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
private static final String TAG = "MainActivity"; private static final String KEY_SELECTED_NAV_MENU = "KEY_SELECTED_NAV_MENU";
private SharedPreferences mSharedPreferences; private String mToken; private DrawerLayout mDrawer; private Handler mHandler; private int mPreviousMenuItemId; private static final String travelShortcut = "io.github.project_travel_mate.TravelShortcut"; private static final String myTripsShortcut = "io.github.project_travel_mate.MyTripsShortcut"; private static final String utilitiesShortcut = "io.github.project_travel_mate.UtilitiesShortcut";
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.bind(this);
}
void defaultSelectedNavMenu(int resId) { NavigationView navigationView = findViewById(R.id.nav_view); Menu menu = navigationView.getMenu(); MenuItem menuItem = menu.findItem(resId); menuItem.setChecked(true); }
@Override public void onBackPressed() { DrawerLayout drawer = findViewById(R.id.drawer_layout); if (drawer != null && drawer.isDrawerOpen(GravityCompat.START)) { drawer.closeDrawer(GravityCompat.START); } else { super.onBackPressed(); } }
// Change fragment on selecting naviagtion drawer item @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) {
}
private Fragment getFragmentByNavMenuItemId(int id) {
}
private void getRuntimePermissions() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { requestPermissions(new String[]{Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.BLUETOOTH, Manifest.permission.BLUETOOTH_ADMIN, Manifest.permission.READ_CONTACTS, Manifest.permission.WRITE_CONTACTS, Manifest.permission.READ_PHONE_STATE, Manifest.permission.WAKE_LOCK, Manifest.permission.INTERNET, Manifest.permission.ACCESS_NETWORK_STATE, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.VIBRATE, }, 0); } } }
public static Intent getStartIntent(Context context) { Intent intent = new Intent(context, MainActivity.class); return intent; }
private void fillNavigationView(String emailId, String imageURL) {
}
private void getProfileInfo() {
}
@Override protected void onResume() { super.onResume(); fillNavigationView(mSharedPreferences.getString(USER_NAME, getString(R.string.app_name)), mSharedPreferences.getString(USER_IMAGE, null)); invalidateOptionsMenu(); }
void showProfileOrTrip(String data) { Uri uri = Uri.parse(data); String userId = uri.getQueryParameter(SHARE_PROFILE_USER_ID_QUERY); String myId = mSharedPreferences.getString(USER_ID, null); Log.v("user id", userId + " " + myId); if (userId != null) { int id = Integer.parseInt(userId); if (!userId.equals(myId)) { Intent intent = FriendsProfileActivity.getStartIntent(MainActivity.this, id); startActivity(intent); } else { Intent intent = ProfileActivity.getStartIntent(MainActivity.this); startActivity(intent); } } else { String tripID = uri.getQueryParameter(SHARE_TRIP_TRIP_ID_QUERY); if (tripID != null) { Log.v("trip id", tripID + " "); Trip trip = new Trip(); trip.setId(tripID); Intent intent = MyTripInfoActivity.getStartIntent(MainActivity.this, trip, false); startActivity(intent); } } }
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.notification_menu, menu); updateNotificationsCount(menu); return true; }
public void updateNotificationsCount(Menu menu) { String uri; uri = API_LINK_V2 + "number-of-unread-notifications"; Log.v(TAG, "url = " + uri);
}
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_notification: Intent intent = NotificationsActivity.getStartIntent(MainActivity.this); startActivity(intent); return true; } return super.onOptionsItemSelected(item); }
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(KEY_SELECTED_NAV_MENU, mPreviousMenuItemId); } }