Skip to content

Commit

Permalink
fix crash bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Null committed Nov 1, 2017
1 parent 50406ef commit 326d291
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,6 @@ class MainActivity : TransitionHelper.MainActivity(), NavigationView.OnNavigatio

navigationView.getHeaderView(0).findViewById<TextView>(R.id.nav_header_username).text = getUsername()
navigationView.getHeaderView(0).findViewById<TextView>(R.id.nav_header_id).text = getUserID()

navigationView.getHeaderView(0).findViewById<ImageView>(R.id.SchoolPowerLogo).setOnLongClickListener {
val pref = getSharedPreferences("other", Activity.MODE_PRIVATE)
val spEditor = pref.edit()
spEditor.putBoolean("developer_mode", !pref.getBoolean("developer_mode", false))
spEditor.apply()
utils.showSnackBar(this@MainActivity, findViewById(R.id.main_coordinate_layout), "Developer Mode: "+pref.getBoolean("developer_mode", false).toString(), false)
true
}
}

private fun initScheduler() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Sample:
*/
class AssignmentItem(json: JSONObject) : Serializable {
val title: String = json.getString("name")
val date: String = SimpleDateFormat("yyyy/MM/dd", Locale.CHINA).format(SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX", Locale.US).parse(json.getString("date")))
var date: String
val percentage: String = json.optString("percent", "--").replace("null", "--") // value like "86.96" or "--"
val score: String = json.optString("score", "--").replace("null", "--") // value like "20" or "--"
val maximumScore: String = json.getString("pointsPossible") // value like "23.0"
Expand All @@ -47,7 +47,11 @@ class AssignmentItem(json: JSONObject) : Serializable {
val includeInFinalGrade: Boolean = json.getString("includeInFinalGrade") == "1"
val weight: String = json.getString("weight")
//val term: String

init{
val temp = SimpleDateFormat("yyyy-MM-dd", Locale.CHINA).parse(json.getString("date").replace("T16:00:00.000Z", ""))
temp.time+=24*60*60*1000
date = SimpleDateFormat("yyyy/MM/dd", Locale.CHINA).format(temp)
}
var isNew = false

fun getDividedScore() = "$score/$maximumScore"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.carbonylgroup.schoolpower.fragments

import android.app.Activity
import android.app.Fragment
import android.content.Intent
import android.graphics.Color
Expand All @@ -9,6 +10,7 @@ import android.support.v4.content.ContextCompat
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import com.carbonylgroup.schoolpower.R
import com.carbonylgroup.schoolpower.activities.MainActivity
Expand Down Expand Up @@ -41,10 +43,16 @@ class AboutFragment : Fragment() {
MainActivity.of(activity).expandToolBar(true, true)
utils = Utils(activity)

(view.findViewById<View>(R.id.about_version_label) as TextView)
.setText(activity.packageManager.getPackageInfo(activity.packageName, 0).versionName)
(view.findViewById<View>(R.id.about_version_label) as TextView).text = activity.packageManager.getPackageInfo(activity.packageName, 0).versionName

view.findViewById<View>(R.id.about_version_cell).setOnClickListener { }
view.findViewById<View>(R.id.about_version_cell).setOnLongClickListener {
val pref = activity.getSharedPreferences("other", Activity.MODE_PRIVATE)
val spEditor = pref.edit()
spEditor.putBoolean("developer_mode", !pref.getBoolean("developer_mode", false))
spEditor.apply()
utils.showSnackBar(activity, view.findViewById(R.id.about_content_parent), "Developer Mode: "+pref.getBoolean("developer_mode", false).toString(), false)
true
}

view.findViewById<View>(R.id.about_changelog_cell).setOnClickListener {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.changelog_address))))
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/about_content.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tool="http://schemas.android.com/tools"
android:id="@+id/about_content_parent"
android:layout_width="match_parent"
android:layout_height="match_parent">

Expand Down

0 comments on commit 326d291

Please sign in to comment.