Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class HomeFragment : Fragment() {
- private var jumlahMonitoring : Int = 0
- private var jumlahHistory: Int = 0
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- val inflater = TransitionInflater.from(requireContext())
- enterTransition = inflater.inflateTransition(R.transition.fade_in)
- exitTransition = inflater.inflateTransition(R.transition.fade_out)
- }
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
- return inflater.inflate(R.layout.fragment_home, container, false)
- }
- override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
- super.onViewCreated(view, savedInstanceState)
- val mPreference = context?.getSharedPreferences("my_esign_preff", Context.MODE_PRIVATE)
- val token = mPreference?.getString("access_token", "")
- Log.e("test","tokendiHome: $token")
- AndroidNetworking.get("http://apps.floo.id:54000/api/v1/mobile/transaction/document-monitoring")
- .addHeaders("Authorization", "Bearer $token")
- .setPriority(Priority.LOW)
- .build()
- .getAsJSONObject(object : JSONObjectRequestListener {
- override fun onResponse(response: JSONObject) {
- try {
- jumlahMonitoring = response.getInt("totalCount")
- Log.e("test", "jumlahMonitoring: $jumlahMonitoring")
- } catch (e: Exception) {
- e.printStackTrace()
- }
- }
- override fun onError(anError: ANError?) {
- }
- })
- AndroidNetworking.get("http://apps.floo.id:54000/api/v1/mobile/transaction/document-history")
- .addHeaders("Authorization", "Bearer $token")
- .setPriority(Priority.LOW)
- .build()
- .getAsJSONObject(object : JSONObjectRequestListener {
- override fun onResponse(response: JSONObject) {
- try {
- jumlahHistory = response.getInt("totalCount")
- Log.e("test", "jumlahHistory: $jumlahHistory")
- } catch (e: Exception) {
- e.printStackTrace()
- }
- }
- override fun onError(anError: ANError?) {
- }
- })
- val pieChart : AAChartModel = AAChartModel()
- .chartType(AAChartType.Bar)
- .title("PI Sign")
- .backgroundColor("#d9f4ff")
- .dataLabelsEnabled(true)
- .series(
- arrayOf(
- AASeriesElement()
- .name("Monitoring")
- .data(arrayOf(jumlahMonitoring)),
- AASeriesElement()
- .name("History")
- .data(arrayOf(jumlahHistory))
- )
- )
- chart_pie.aa_drawChartWithChartModel(pieChart)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement