Skip to content

Commit

Permalink
reworked system
Browse files Browse the repository at this point in the history
  • Loading branch information
sinichi449 committed Aug 23, 2019
1 parent 0a8d842 commit 2849d10
Show file tree
Hide file tree
Showing 10 changed files with 160 additions and 158 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.

7 changes: 4 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
compileSdkVersion 29
buildToolsVersion "29.0.1"
defaultConfig {
applicationId "com.sinichi.parentingcontrol"
minSdkVersion 15
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "0.2-beta"
Expand All @@ -30,6 +31,6 @@ dependencies {
implementation 'androidx.recyclerview:recyclerview:1.1.0-beta03'
implementation 'com.squareup.retrofit2:retrofit:2.6.1'
implementation 'com.squareup.retrofit2:converter-gson:2.6.1'
implementation 'android.arch.persistence.room:runtime:1.1.1'
annotationProcessor 'android.arch.persistence.room:compiler:1.1.1'
implementation 'com.google.firebase:firebase-database:19.0.0'
implementation 'com.google.firebase:firebase-analytics:17.0.1'
}
67 changes: 58 additions & 9 deletions app/src/main/java/com/sinichi/parentingcontrol/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.sinichi.parentingcontrol;

import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
Expand All @@ -9,13 +8,17 @@
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.room.Room;

import com.sinichi.parentingcontrol.db.MyDatabase;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import com.sinichi.parentingcontrol.model.Model;
import com.sinichi.parentingcontrol.recycleadapter.RvAdapter;

Expand All @@ -24,18 +27,17 @@

public class MainActivity extends AppCompatActivity {

private MyDatabase database;
private View view;
private RecyclerView rv;
private RvAdapter rvAdapter;
private List<Model> dataList = new ArrayList<>();
private ImageView imgAddItem;
private DatabaseReference databaseReference;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
database = Room.databaseBuilder(MainActivity.this, MyDatabase.class, "dataAnak").build();

initComponents();

Expand All @@ -46,7 +48,7 @@ public void onClick(View view) {
//TODO: Buat AlertDialog Membantu Orang Tua
makeMembantuOrtuDialog();
//TODO: Buat AlertDialog Sekolah

makeSekolahDialog();
}
});
}
Expand All @@ -55,11 +57,30 @@ private void initComponents() {
imgAddItem = findViewById(R.id.img_addItems);
rv = findViewById(R.id.rv_catatan);

LayoutInflater inflater = getLayoutInflater();
View v = inflater.inflate(R.layout.layout_item, null);

final CheckBox chkMembantuOrtu = v.findViewById(R.id.chkbx_membantuOrtu);

databaseReference = FirebaseDatabase.getInstance().getReference().child("membantuOrtu");
databaseReference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
boolean membantuOrtu = dataSnapshot.getValue(boolean.class);
chkMembantuOrtu.setChecked(membantuOrtu);
}

@Override
public void onCancelled(@NonNull DatabaseError databaseError) {

}
});

newItemForNewDay();
}

private void addNewModel(String tanggal, String hari, String bulan, String tahun, String jumlahSholat, boolean isMembantuOrangTua, boolean isSekolah) {
Model model = new Model(tanggal, hari, bulan, tahun, jumlahSholat, isMembantuOrangTua, isSekolah);
Model model = new Model(tanggal, hari, bulan, tahun, jumlahSholat, isMembantuOrangTua, isSekolah); // temp data
dataList.add(model);
rvAdapter = new RvAdapter(dataList);
rv.setAdapter(rvAdapter);
Expand All @@ -81,7 +102,7 @@ private void makeMembantuOrtuDialog() {
@Override
public void onClick(View view) {
//TODO: Edit datalist bagian membantu orang tua menjadi tercentang

databaseReference.setValue(true);
alertDialog.dismiss();
}
});
Expand All @@ -90,12 +111,40 @@ public void onClick(View view) {
@Override
public void onClick(View view) {
//TODO: Edit dataList bagian membantu orang tua menjadi tidak tercentang

databaseReference.setValue(false);
alertDialog.dismiss();
}
});
}

private void makeSekolahDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
LayoutInflater inflater = getLayoutInflater();
View dialogView = inflater.inflate(R.layout.layout_dialogsklhbg, null);
builder.setView(dialogView);
AlertDialog alertDialog = builder.create();
alertDialog.show();

ImageView imgCeklisSklh = dialogView.findViewById(R.id.img_ceklilsSklh);
ImageView imgSilangSklh = dialogView.findViewById(R.id.img_silangSklh);

imgCeklisSklh.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//TODO: Aktifkan ceklis pada sekolah

}
});

imgSilangSklh.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//TODO: Nonaktifkan ceklis pada sekolah

}
});
}

private void newItemForNewDay() {
CurrentDimension cd = new CurrentDimension();
LayoutInflater inflater = getLayoutInflater();
Expand Down
10 changes: 0 additions & 10 deletions app/src/main/java/com/sinichi/parentingcontrol/db/MyDatabase.java

This file was deleted.

108 changes: 0 additions & 108 deletions app/src/main/java/com/sinichi/parentingcontrol/db/Users.java

This file was deleted.

25 changes: 0 additions & 25 deletions app/src/main/java/com/sinichi/parentingcontrol/db/UsersDao.java

This file was deleted.

3 changes: 2 additions & 1 deletion app/src/main/res/layout/layout_dialogbg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
android:layout_height="40dp"
android:layout_weight="1"
app:srcCompat="@drawable/ic_silang"
android:layout_marginBottom="24dp"/>
android:layout_marginBottom="24dp"
/>
</LinearLayout>

</LinearLayout>
45 changes: 45 additions & 0 deletions app/src/main/res/layout/layout_dialogsklhbg.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:text="Lorem ipsum dolor sit amet, sekolah?"
android:textStyle="bold"
android:fontFamily="sans-serif"
android:textColor="#000"
android:textSize="24sp"
android:gravity="center"
android:layout_marginTop="24dp"/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2"
android:layout_marginTop="20dp">

<ImageView
android:id="@+id/img_ceklilsSklh"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_weight="1"
app:srcCompat="@drawable/ic_ceklis"
android:layout_marginBottom="24dp"/>

<ImageView
android:id="@+id/img_silangSklh"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_weight="1"
app:srcCompat="@drawable/ic_silang"
android:layout_marginBottom="24dp"/>
</LinearLayout>

</LinearLayout>
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'

classpath 'com.google.gms:google-services:4.2.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down
Loading

0 comments on commit 2849d10

Please sign in to comment.