Skip to content
This repository has been archived by the owner on Aug 5, 2023. It is now read-only.

Commit

Permalink
delete unnecessary images
Browse files Browse the repository at this point in the history
  • Loading branch information
whoishusni committed Mar 27, 2020
1 parent 8310a06 commit 35d8e7e
Show file tree
Hide file tree
Showing 17 changed files with 269 additions and 150 deletions.
7 changes: 3 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ android {
applicationId "id.husni.covninfo"
minSdkVersion 22
targetSdkVersion 28
versionCode 4
versionName '2.5'
versionCode 5
versionName '3.0'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
buildConfigField("String", "API_NEWS", '"{USE YOUR API FROM APINEWS HERE (Api APINEWS Disini)}"')

}
buildTypes {
release {
Expand Down Expand Up @@ -40,8 +41,6 @@ dependencies {
implementation 'com.squareup.retrofit2:converter-gson:2.7.0'
//Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.7.0'
//MPChart
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
//RecyvlerView
implementation 'androidx.recyclerview:recyclerview:1.1.0'
//CardView
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
android:roundIcon="@drawable/icon"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".activity.WorldHistory" />
<activity android:name=".activity.NewsDetail" />
<activity android:name=".activity.IndonesiaProvinceActivity" />
<activity
Expand Down
13 changes: 0 additions & 13 deletions app/src/main/java/id/husni/covninfo/activity/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@
import com.google.android.material.bottomnavigation.BottomNavigationView;

import id.husni.covninfo.R;
import id.husni.covninfo.activity.AboutActivity;
import id.husni.covninfo.activity.InfoActivity;
import id.husni.covninfo.activity.SettingActivity;
import id.husni.covninfo.fragment.IdnFragment;
import id.husni.covninfo.fragment.HistoryFragment;
import id.husni.covninfo.fragment.NewsFragment;
import id.husni.covninfo.fragment.SummaryFragment;

Expand Down Expand Up @@ -67,15 +63,6 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
.commit();
return true;

//Ke Fragment Today
case R.id.historyMenu:
HistoryFragment historyFragment = new HistoryFragment();
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.main_frame, historyFragment)
.commit();
return true;

//ke Fragment News
case R.id.newsMenu:
NewsFragment newsFragment = new NewsFragment();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,18 @@
* Not for Commercial Purpose
*/

package id.husni.covninfo.fragment;
package id.husni.covninfo.activity;


import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;

import android.view.LayoutInflater;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.ArrayList;
Expand All @@ -30,46 +25,38 @@
import id.husni.covninfo.model.HistoryModel;
import id.husni.covninfo.viewmodel.HistoryViewModel;

/**
* A simple {@link Fragment} subclass.
*/
public class HistoryFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener {

public class WorldHistory extends AppCompatActivity implements SwipeRefreshLayout.OnRefreshListener {
private HistoryListAdapter adapter;
private TextView tvEmptyList;
private SwipeRefreshLayout swipeRefreshLayout;
public HistoryFragment() {
// Required empty public constructor
}


@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_history, container, false);
}

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_world_history);
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle(R.string.history);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}

tvEmptyList = view.findViewById(R.id.tvEmptyList);
tvEmptyList = findViewById(R.id.tvEmptyList);

swipeRefreshLayout = view.findViewById(R.id.swipeRefreshList);
RecyclerView recyclerView = view.findViewById(R.id.listRecycler);
swipeRefreshLayout = findViewById(R.id.swipeRefreshList);
RecyclerView recyclerView = findViewById(R.id.listRecycler);

adapter = new HistoryListAdapter(getContext());
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
adapter = new HistoryListAdapter(this);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(adapter);
loadListData();

swipeRefreshLayout.setOnRefreshListener(this);
}

@Override
public void onRefresh() {
loadListData();
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
onBackPressed();
}
return super.onOptionsItemSelected(item);
}

private void loadListData() {
Expand All @@ -89,12 +76,16 @@ public void onChanged(ArrayList<HistoryModel> historyModels) {
}
});
}

private void refreshingData(boolean isRefresh) {
if (isRefresh) {
swipeRefreshLayout.setRefreshing(true);
} else {
swipeRefreshLayout.setRefreshing(false);
}
}

@Override
public void onRefresh() {
loadListData();
}
}
26 changes: 14 additions & 12 deletions app/src/main/java/id/husni/covninfo/fragment/IdnFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
/**
* A simple {@link Fragment} subclass.
*/
public class IdnFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener {
public class IdnFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener, View.OnClickListener {

private SwipeRefreshLayout swipe;
private TextView tvPositive;
Expand All @@ -60,13 +60,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
tvPositive = view.findViewById(R.id.tvValuePositifIdn);
tvRecovered = view.findViewById(R.id.tvValueRecoveredIdn);
tvDeath = view.findViewById(R.id.tvValueDeathsIdn);
floatingProvince.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent provinceIntent = new Intent(getContext(), IndonesiaProvinceActivity.class);
startActivity(provinceIntent);
}
});
floatingProvince.setOnClickListener(this);
loadIdnData();
}

Expand All @@ -77,10 +71,12 @@ private void loadIdnData() {
viewModel.getSummaryData().observe(this, new Observer<ArrayList<IndonesiaSummaryModel>>() {
@Override
public void onChanged(ArrayList<IndonesiaSummaryModel> indonesiaSummaryModels) {
refreshData(false);
tvPositive.setText(indonesiaSummaryModels.get(0).getPositifIdn());
tvRecovered.setText(indonesiaSummaryModels.get(0).getSembuhIdn());
tvDeath.setText(indonesiaSummaryModels.get(0).getMeninggalIdn());
if (indonesiaSummaryModels.size() > 0) {
refreshData(false);
tvPositive.setText(indonesiaSummaryModels.get(0).getPositifIdn());
tvRecovered.setText(indonesiaSummaryModels.get(0).getSembuhIdn());
tvDeath.setText(indonesiaSummaryModels.get(0).getMeninggalIdn());
}
}
});
}
Expand All @@ -97,4 +93,10 @@ private void refreshData(boolean isRefresh) {
public void onRefresh() {
loadIdnData();
}

@Override
public void onClick(View view) {
Intent provinceIntent = new Intent(getContext(), IndonesiaProvinceActivity.class);
startActivity(provinceIntent);
}
}
93 changes: 51 additions & 42 deletions app/src/main/java/id/husni/covninfo/fragment/SummaryFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,39 @@
package id.husni.covninfo.fragment;


import android.graphics.Color;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;

import com.github.mikephil.charting.charts.PieChart;
import com.github.mikephil.charting.components.Description;
import com.github.mikephil.charting.components.Legend;
import com.github.mikephil.charting.data.PieData;
import com.github.mikephil.charting.data.PieDataSet;
import com.github.mikephil.charting.data.PieEntry;
import com.github.mikephil.charting.utils.ColorTemplate;
import com.google.android.material.floatingactionbutton.FloatingActionButton;

import java.util.ArrayList;
import java.util.List;
import java.text.NumberFormat;
import java.util.Locale;

import id.husni.covninfo.R;
import id.husni.covninfo.activity.WorldHistory;
import id.husni.covninfo.model.WorldSummaryModel;
import id.husni.covninfo.viewmodel.WorldSummaryViewModel;

/**
* A simple {@link Fragment} subclass.
*/
public class SummaryFragment extends Fragment {

public class SummaryFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener, View.OnClickListener {

private SwipeRefreshLayout swipe;
private TextView tvPositive;
private TextView tvRecovered;
private TextView tvDeaths;
public SummaryFragment() {
// Required empty public constructor
}
Expand All @@ -55,42 +55,51 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
PieChart pieChart = view.findViewById(R.id.worldSummaryPie);
swipe = view.findViewById(R.id.swipeRefreshWorld);
swipe.setOnRefreshListener(this);
FloatingActionButton floating = view.findViewById(R.id.floatingWorld);
floating.setOnClickListener(this);
tvPositive = view.findViewById(R.id.tvValuePositifWorld);
tvRecovered = view.findViewById(R.id.tvValueRecoveredWorld);
tvDeaths = view.findViewById(R.id.tvValueDeathsWorld);
loadWorldData();
}

private void loadWorldData() {
WorldSummaryViewModel viewModel = new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory()).get(WorldSummaryViewModel.class);
viewModel.setSummaryWorldData();
refreshData(true);
viewModel.getSummaryWorldData().observe(this, new Observer<WorldSummaryModel>() {
@Override
public void onChanged(WorldSummaryModel worldSummaryModel) {
//Set data to Chart
List<PieEntry> entries = new ArrayList<>();
entries.add(new PieEntry(worldSummaryModel.getConfirmed().getValue(),getResources().getString(R.string.confirmed)));
entries.add(new PieEntry(worldSummaryModel.getRecovered().getValue(),getResources().getString(R.string.recovered)));
entries.add(new PieEntry(worldSummaryModel.getDeaths().getValue(),getResources().getString(R.string.deaths)));

PieDataSet pieDataSet = new PieDataSet(entries, getResources().getString(R.string.from_corona));
pieDataSet.setColors(ColorTemplate.PASTEL_COLORS);
pieDataSet.setValueTextColor(Color.WHITE);
pieDataSet.setValueTextSize(20);

PieData pieData = new PieData(pieDataSet);

Description description = new Description();
description.setText(getResources().getString(R.string.source_JHU));
description.setTextColor(Color.WHITE);
description.setTextSize(14);

Legend legend = pieChart.getLegend();
legend.setTextColor(Color.WHITE);
legend.setTextSize(13);
legend.setForm(Legend.LegendForm.CIRCLE);

pieChart.setVisibility(View.VISIBLE);
pieChart.animateXY(2000,2000);
pieChart.setDescription(description);
pieChart.setHoleColor(getResources().getColor(R.color.colorPrimaryDark));
pieChart.setHoleRadius(60);
pieChart.setData(pieData);
if (worldSummaryModel != null) {
refreshData(false);
Locale localeID = new Locale("id","ID");
NumberFormat numberFormat = NumberFormat.getInstance(localeID);
tvPositive.setText(String.valueOf(numberFormat.format(worldSummaryModel.getConfirmed().getValue())));
tvRecovered.setText(String.valueOf(numberFormat.format(worldSummaryModel.getRecovered().getValue())));
tvDeaths.setText(String.valueOf(numberFormat.format(worldSummaryModel.getDeaths().getValue())));
}
}
});
}

private void refreshData(boolean isRefresh) {
if (isRefresh) {
swipe.setRefreshing(true);
} else {
swipe.setRefreshing(false);
}
}

@Override
public void onRefresh() {
loadWorldData();
}

@Override
public void onClick(View view) {
Intent intentWorldHistory = new Intent(getContext(), WorldHistory.class);
startActivity(intentWorldHistory);
}
}
5 changes: 0 additions & 5 deletions app/src/main/res/drawable/ic_today.xml

This file was deleted.

4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_about.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@
android:textSize="14sp" />

<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/aboutTextDatabaseTwo"
Expand Down Expand Up @@ -179,7 +178,8 @@
android:backgroundTint="@color/colorAccent"
android:drawableTop="@drawable/ic_person_black_24dp"
android:text="@string/github"
android:textColor="@android:color/white" />
android:textColor="@android:color/white"
android:layout_marginBottom="30dp"/>

</LinearLayout>
</ScrollView>
1 change: 0 additions & 1 deletion app/src/main/res/layout/activity_splash.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
app:layout_constraintTop_toBottomOf="@+id/imageView" />

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/for_human"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimaryDark"
tools:context=".fragment.HistoryFragment">
tools:context=".activity.WorldHistory">

<LinearLayout
android:id="@+id/linearLayout2"
Expand Down
Loading

0 comments on commit 35d8e7e

Please sign in to comment.