diff --git a/app/build.gradle b/app/build.gradle index 52fc545..190e28c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,7 +8,7 @@ android { minSdkVersion 16 targetSdkVersion 27 versionCode 2 - versionName "2.6.2" + versionName "2.6.3" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { diff --git a/app/src/main/java/com/arvind/quote/MainActivity.java b/app/src/main/java/com/arvind/quote/MainActivity.java index de123e0..9941f4c 100644 --- a/app/src/main/java/com/arvind/quote/MainActivity.java +++ b/app/src/main/java/com/arvind/quote/MainActivity.java @@ -65,7 +65,8 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen // to make sure the same fragment isn't instantiated again private MenuItem previousItem; private BottomNavigationView bottomNavigationView; - + // Root Layout + private RelativeLayout rootLayout; // Updater Instance private UpdaterUtils updaterUtils; // AlertDialog in which UpdaterStuff would be shown @@ -206,7 +207,7 @@ public void onClick(View view) { // Set background of the Navigation drawer view navigationView.setBackgroundColor(getResources().getColor(cardViewBackGround)); - RelativeLayout rootLayout = findViewById(R.id.root_layout); + rootLayout = findViewById(R.id.root_layout); if (themeKey.equals("translucent")) { AnimationDrawable anim = (AnimationDrawable) rootLayout.getBackground(); @@ -295,6 +296,10 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) { drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); } + startUpdater(); + } + + public void startUpdater() { // UpdaterUtils Instance // Checks for Updates - Uses GitHub Releases/Tags System with GitHub API v3 updaterUtils = new UpdaterUtils(this.getApplicationContext(), this); diff --git a/app/src/main/java/com/arvind/quote/adapter/QuoteAdapter.java b/app/src/main/java/com/arvind/quote/adapter/QuoteAdapter.java index a97ecb4..5020a4b 100644 --- a/app/src/main/java/com/arvind/quote/adapter/QuoteAdapter.java +++ b/app/src/main/java/com/arvind/quote/adapter/QuoteAdapter.java @@ -85,7 +85,6 @@ public class QuoteViewHolder extends RecyclerView.ViewHolder { authorTextView = itemView.findViewById(R.id.author_text_view); starQuoteView = itemView.findViewById(R.id.star_quote_button); - starQuoteView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/java/com/arvind/quote/utils/UpdaterUtils.java b/app/src/main/java/com/arvind/quote/utils/UpdaterUtils.java index 56baa3f..b282293 100644 --- a/app/src/main/java/com/arvind/quote/utils/UpdaterUtils.java +++ b/app/src/main/java/com/arvind/quote/utils/UpdaterUtils.java @@ -102,26 +102,24 @@ public void onResponse(JSONArray response) { .replaceAll(".*/", ""); // Variable to hold current Tag's position in the list of tags - int currentVersionPosition; + int currentVersionPosition = -1; // Get Position of currentVersion Tag in the tags List - String interVersion = null; - for (currentVersionPosition = 0; currentVersionPosition < response.length(); currentVersionPosition++) { - interVersion = response - .getJSONObject(currentVersionPosition) + String interVersion[] = new String[response.length()]; + for(int i = 0; i < interVersion.length; i++) { + interVersion[i] = response.getJSONObject(i) .getString("ref") .replaceAll(".*/", ""); - // If the intermediate version equals current, then break the loop - if (interVersion.equals(currentVersion)) - break; + if(currentVersion.equals(interVersion[i])) + currentVersionPosition = i; } // If currentVersion is at the End, we're updated - boolean isAtEnd = currentVersionPosition == response.length(); + boolean isAtEnd = currentVersionPosition == (response.length() - 1); // If we're at end, and the End Version not equals Current Version // >> deb Mode enabled - boolean isDev = isAtEnd && !interVersion.equals(currentVersion); - if (isDev) { + boolean isDev = isAtEnd && (currentVersionPosition == -1); + if(isDev) { Log.d(TAG, "Hello Debluper"); Toast.makeText(context, "Hello Debluper", @@ -131,7 +129,7 @@ public void onResponse(JSONArray response) { Toast.makeText(context, "We're updated!", Toast.LENGTH_LONG).show(); - } else { // We're not + } else { // We're not updated // The total number of Tag Requests tagRequestCount = (response.length() - 1) + currentVersionPosition; // Creating changeLog message array