0% found this document useful (0 votes)
2 views20 pages

Java

The document contains the layout and Java code for a splash screen and main menu of an Android application. The splash screen is defined in XML with various LinearLayouts and a ProgressBar, while the Java code initializes the UI components and transitions to the main menu after a delay. The main menu includes a navigation drawer and various UI elements, with event listeners for user interactions.

Uploaded by

ahmad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views20 pages

Java

The document contains the layout and Java code for a splash screen and main menu of an Android application. The splash screen is defined in XML with various LinearLayouts and a ProgressBar, while the Java code initializes the UI components and transitions to the main menu after a delay. The main menu includes a navigation drawer and various UI elements, with event listeners for user interactions.

Uploaded by

ahmad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 20

1.

Splash screen

a. Main.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/linear5"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="8dp"
android:background="@drawable/bg1"
android:gravity="center_horizontal|center_vertical"
android:orientation="vertical"
android:layout_gravity="center_horizontal">
<LinearLayout
android:id="@+id/linear6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:orientation="horizontal" />
<LinearLayout
android:id="@+id/linear9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageview1"
android:layout_width="150dp"
android:layout_height="150dp"
android:src="@drawable/logo"
android:scaleType="centerInside"
android:layout_gravity="center_horizontal|
center_vertical" />
</LinearLayout>
<LinearLayout
android:id="@+id/linear8"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:orientation="horizontal" />
<LinearLayout
android:id="@+id/linear7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:orientation="horizontal" />
<LinearLayout
android:id="@+id/linear10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:orientation="horizontal" />
<ProgressBar
android:id="@+id/progressbar2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:indeterminate="false"
style="?android:progressBarStyle" />
</LinearLayout>
</LinearLayout>
b. Main.java
package com.my.smkdh;

import android.animation.*;
import android.app.*;
import android.content.*;
import android.content.Intent;
import android.content.res.*;
import android.graphics.*;
import android.graphics.drawable.*;
import android.media.*;
import android.net.*;
import android.net.Uri;
import android.os.*;
import android.text.*;
import android.text.style.*;
import android.util.*;
import android.view.*;
import android.view.View.*;
import android.view.animation.*;
import android.webkit.*;
import android.widget.*;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import androidx.annotation.*;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import java.io.*;
import java.text.*;
import java.util.*;
import java.util.Timer;
import java.util.TimerTask;
import java.util.regex.*;
import org.json.*;

public class MainActivity extends AppCompatActivity {

private Timer _timer = new Timer();

private LinearLayout linear5;


private LinearLayout linear6;
private LinearLayout linear9;
private LinearLayout linear8;
private LinearLayout linear7;
private LinearLayout linear10;
private ProgressBar progressbar2;
private ImageView imageview1;

private Intent i = new Intent();


private TimerTask t;
@Override
protected void onCreate(Bundle _savedInstanceState) {
super.onCreate(_savedInstanceState);
setContentView(R.layout.main);
initialize(_savedInstanceState);
initializeLogic();
}

private void initialize(Bundle _savedInstanceState) {


linear5 = findViewById(R.id.linear5);
linear6 = findViewById(R.id.linear6);
linear9 = findViewById(R.id.linear9);
linear8 = findViewById(R.id.linear8);
linear7 = findViewById(R.id.linear7);
linear10 = findViewById(R.id.linear10);
progressbar2 = findViewById(R.id.progressbar2);
imageview1 = findViewById(R.id.imageview1);

linear9.setOnLongClickListener(new
View.OnLongClickListener() {
@Override
public boolean onLongClick(View _view) {

return true;
}
});
}

private void initializeLogic() {


progressbar2.setIndeterminate(true);
progressbar2.setIndeterminate(true);
t = new TimerTask() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {

i.setClass(getApplicationContext(), MenuActivity.class);
startActivity(i);
finish();
}
});
}
};
_timer.schedule(t, (int)(2000));
}

@Deprecated
public void showMessage(String _s) {
Toast.makeText(getApplicationContext(), _s,
Toast.LENGTH_SHORT).show();
}

@Deprecated
public int getLocationX(View _v) {
int _location[] = new int[2];
_v.getLocationInWindow(_location);
return _location[0];
}

@Deprecated
public int getLocationY(View _v) {
int _location[] = new int[2];
_v.getLocationInWindow(_location);
return _location[1];
}

@Deprecated
public int getRandom(int _min, int _max) {
Random random = new Random();
return random.nextInt(_max - _min + 1) + _min;
}

@Deprecated
public ArrayList<Double>
getCheckedItemPositionsToArray(ListView _list) {
ArrayList<Double> _result = new ArrayList<Double>();
SparseBooleanArray _arr = _list.getCheckedItemPositions();
for (int _iIdx = 0; _iIdx < _arr.size(); _iIdx++) {
if (_arr.valueAt(_iIdx))
_result.add((double)_arr.keyAt(_iIdx));
}
return _result;
}

@Deprecated
public float getDip(int _input) {
return
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, _input,
getResources().getDisplayMetrics());
}

@Deprecated
public int getDisplayWidthPixels() {
return getResources().getDisplayMetrics().widthPixels;
}

@Deprecated
public int getDisplayHeightPixels() {
return getResources().getDisplayMetrics().heightPixels;
}
}
2. MENU UTAMA

a. Menu.java
package com.my.smkdh;

import android.animation.*;
import android.app.*;
import android.content.*;
import android.content.Intent;
import android.content.res.*;
import android.graphics.*;
import android.graphics.drawable.*;
import android.media.*;
import android.net.*;
import android.net.Uri;
import android.os.*;
import android.text.*;
import android.text.style.*;
import android.util.*;
import android.view.*;
import android.view.View;
import android.view.View.*;
import android.view.animation.*;
import android.webkit.*;
import android.widget.*;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.*;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import com.google.android.material.appbar.AppBarLayout;
import java.io.*;
import java.text.*;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Timer;
import java.util.TimerTask;
import java.util.regex.*;
import org.json.*;

public class MenuActivity extends AppCompatActivity {

private Timer _timer = new Timer();

private Toolbar _toolbar;


private AppBarLayout _app_bar;
private CoordinatorLayout _coordinator;
private DrawerLayout _drawer;
private String jsonKota = "";
private double p2 = 0;
private String url = "";
private HashMap<String, Object> map1 = new HashMap<>();
private String data2 = "";
private HashMap<String, Object> map2 = new HashMap<>();
private String json_jadwal = "";
private HashMap<String, Object> mapjadwal = new HashMap<>();

private ArrayList<HashMap<String, Object>> dataKota = new


ArrayList<>();
private ArrayList<String> listKota = new ArrayList<>();
private LinearLayout linear1;
private TextView textview1;
private TextView textview3;
private LinearLayout linear2;
private LinearLayout linear13;
private TextView textview4;
private LinearLayout linear10;
private LinearLayout linear11;
private LinearLayout linear12;
private LinearLayout linear14;
private TextView textview7;
private TextView text_imsak;
private TextView textview9;
private TextView text_subuh;
private TextView textview11;
private TextView text_terbit;
private TextView textview13;
private TextView text_dzuhur;
private LinearLayout _drawer_linear1;
private LinearLayout _drawer_linear2;
private LinearLayout _drawer_linear3;
private LinearLayout _drawer_doapagii;
private LinearLayout _drawer_linear5;
private LinearLayout _drawer_linear6;
private LinearLayout _drawer_linear7;
private LinearLayout _drawer_linear8;
private LinearLayout _drawer_linear9;
private LinearLayout _drawer_linear10;
private LinearLayout _drawer_linear11;
private LinearLayout _drawer_linear12;
private LinearLayout _drawer_linear13;
private LinearLayout _drawer_linear14;
private LinearLayout _drawer_linear15;
private LinearLayout _drawer_linear16;
private ImageView _drawer_imageview1;
private TextView _drawer_doapagi;
private ImageView _drawer_imageview2;
private ImageView _drawer_imageview5;
private TextView _drawer_zikirdandoa;
private ImageView _drawer_imageview6;
private ImageView _drawer_imageview9;
private TextView _drawer_albarzanji;
private ImageView _drawer_imageview10;
private ImageView _drawer_imageview11;
private TextView _drawer_hizib;
private ImageView _drawer_imageview12;
private ImageView _drawer_imageview13;
private TextView _drawer_doapilihan;
private ImageView _drawer_imageview14;
private ImageView _drawer_imageview15;
private TextView _drawer_ujian;
private ImageView _drawer_imageview16;

private Intent p = new Intent();


private Calendar c = Calendar.getInstance();
private TimerTask t;

@Override
protected void onCreate(Bundle _savedInstanceState) {
super.onCreate(_savedInstanceState);
setContentView(R.layout.menu);
initialize(_savedInstanceState);
initializeLogic();
}

private void initialize(Bundle _savedInstanceState) {


_app_bar = findViewById(R.id._app_bar);
_coordinator = findViewById(R.id._coordinator);
_toolbar = findViewById(R.id._toolbar);
setSupportActionBar(_toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
_toolbar.setNavigationOnClickListener(new
View.OnClickListener() {
@Override
public void onClick(View _v) {
onBackPressed();
}
});
_drawer = findViewById(R.id._drawer);
ActionBarDrawerToggle _toggle = new
ActionBarDrawerToggle(MenuActivity.this, _drawer, _toolbar,
R.string.app_name, R.string.app_name);
_drawer.addDrawerListener(_toggle);
_toggle.syncState();

LinearLayout _nav_view = findViewById(R.id._nav_view);


linear1 = findViewById(R.id.linear1);
textview1 = findViewById(R.id.textview1);
textview3 = findViewById(R.id.textview3);
linear2 = findViewById(R.id.linear2);
linear13 = findViewById(R.id.linear13);
textview4 = findViewById(R.id.textview4);
linear10 = findViewById(R.id.linear10);
linear11 = findViewById(R.id.linear11);
linear12 = findViewById(R.id.linear12);
linear14 = findViewById(R.id.linear14);
textview7 = findViewById(R.id.textview7);
text_imsak = findViewById(R.id.text_imsak);
textview9 = findViewById(R.id.textview9);
text_subuh = findViewById(R.id.text_subuh);
textview11 = findViewById(R.id.textview11);
text_terbit = findViewById(R.id.text_terbit);
textview13 = findViewById(R.id.textview13);
text_dzuhur = findViewById(R.id.text_dzuhur);
_drawer_linear1 = _nav_view.findViewById(R.id.linear1);
_drawer_linear2 = _nav_view.findViewById(R.id.linear2);
_drawer_linear3 = _nav_view.findViewById(R.id.linear3);
_drawer_doapagii = _nav_view.findViewById(R.id.doapagii);
_drawer_linear5 = _nav_view.findViewById(R.id.linear5);
_drawer_linear6 = _nav_view.findViewById(R.id.linear6);
_drawer_linear7 = _nav_view.findViewById(R.id.linear7);
_drawer_linear8 = _nav_view.findViewById(R.id.linear8);
_drawer_linear9 = _nav_view.findViewById(R.id.linear9);
_drawer_linear10 = _nav_view.findViewById(R.id.linear10);
_drawer_linear11 = _nav_view.findViewById(R.id.linear11);
_drawer_linear12 = _nav_view.findViewById(R.id.linear12);
_drawer_linear13 = _nav_view.findViewById(R.id.linear13);
_drawer_linear14 = _nav_view.findViewById(R.id.linear14);
_drawer_linear15 = _nav_view.findViewById(R.id.linear15);
_drawer_linear16 = _nav_view.findViewById(R.id.linear16);
_drawer_imageview1 =
_nav_view.findViewById(R.id.imageview1);
_drawer_doapagi = _nav_view.findViewById(R.id.doapagi);
_drawer_imageview2 =
_nav_view.findViewById(R.id.imageview2);
_drawer_imageview5 =
_nav_view.findViewById(R.id.imageview5);
_drawer_zikirdandoa =
_nav_view.findViewById(R.id.zikirdandoa);
_drawer_imageview6 =
_nav_view.findViewById(R.id.imageview6);
_drawer_imageview9 =
_nav_view.findViewById(R.id.imageview9);
_drawer_albarzanji =
_nav_view.findViewById(R.id.albarzanji);
_drawer_imageview10 =
_nav_view.findViewById(R.id.imageview10);
_drawer_imageview11 =
_nav_view.findViewById(R.id.imageview11);
_drawer_hizib = _nav_view.findViewById(R.id.hizib);
_drawer_imageview12 =
_nav_view.findViewById(R.id.imageview12);
_drawer_imageview13 =
_nav_view.findViewById(R.id.imageview13);
_drawer_doapilihan =
_nav_view.findViewById(R.id.doapilihan);
_drawer_imageview14 =
_nav_view.findViewById(R.id.imageview14);
_drawer_imageview15 =
_nav_view.findViewById(R.id.imageview15);
_drawer_ujian = _nav_view.findViewById(R.id.ujian);
_drawer_imageview16 =
_nav_view.findViewById(R.id.imageview16);

_drawer_doapagii.setOnLongClickListener(new
View.OnLongClickListener() {
@Override
public boolean onLongClick(View _view) {
_drawer.closeDrawer(GravityCompat.START);
p.setClass(getApplicationContext(),
DoapagiActivity.class);
startActivity(p);
return true;
}
});

_drawer_doapagi.setOnLongClickListener(new
View.OnLongClickListener() {
@Override
public boolean onLongClick(View _view) {
_drawer.closeDrawer(GravityCompat.START);
p.setClass(getApplicationContext(),
DoapagiActivity.class);
startActivity(p);
return true;
}
});

_drawer_doapagi.setOnClickListener(new
View.OnClickListener() {
@Override
public void onClick(View _view) {
p.setClass(getApplicationContext(),
DoapagiActivity.class);
startActivity(p);
}
});

_drawer_zikirdandoa.setOnLongClickListener(new
View.OnLongClickListener() {
@Override
public boolean onLongClick(View _view) {
p.setClass(getApplicationContext(),
ZikirdandoaActivity.class);
startActivity(p);
return true;
}
});

_drawer_zikirdandoa.setOnClickListener(new
View.OnClickListener() {
@Override
public void onClick(View _view) {
p.setClass(getApplicationContext(),
ZikirdandoaActivity.class);
startActivity(p);
}
});

_drawer_albarzanji.setOnLongClickListener(new
View.OnLongClickListener() {
@Override
public boolean onLongClick(View _view) {
p.setClass(getApplicationContext(),
AlbarzajiActivity.class);
startActivity(p);
return true;
}
});

_drawer_albarzanji.setOnClickListener(new
View.OnClickListener() {
@Override
public void onClick(View _view) {
p.setClass(getApplicationContext(),
AlbarzajiActivity.class);
startActivity(p);
}
});

_drawer_hizib.setOnLongClickListener(new
View.OnLongClickListener() {
@Override
public boolean onLongClick(View _view) {
p.setClass(getApplicationContext(),
HizibActivity.class);
startActivity(p);
return true;
}
});

_drawer_hizib.setOnClickListener(new
View.OnClickListener() {
@Override
public void onClick(View _view) {
p.setClass(getApplicationContext(),
HizibActivity.class);
startActivity(p);
}
});

_drawer_doapilihan.setOnLongClickListener(new
View.OnLongClickListener() {
@Override
public boolean onLongClick(View _view) {
p.setClass(getApplicationContext(),
DoapilihanActivity.class);
startActivity(p);
return true;
}
});
_drawer_doapilihan.setOnClickListener(new
View.OnClickListener() {
@Override
public void onClick(View _view) {
p.setClass(getApplicationContext(),
DoapilihanActivity.class);
startActivity(p);
}
});

_drawer_ujian.setOnClickListener(new
View.OnClickListener() {
@Override
public void onClick(View _view) {
p.setClass(getApplicationContext(),
WebActivity.class);
startActivity(p);
}
});
}

private void initializeLogic() {


t = new TimerTask() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
c = Calendar.getInstance();
textview1.setText(new
SimpleDateFormat("dd / MMMM / yyyy").format(c.getTime()));
textview3.setText(new
SimpleDateFormat("H : mm . ss").format(c.getTime()));
}
});
}
};
_timer.scheduleAtFixedRate(t, (int)(0), (int)(1000));
}

@Override
public void onBackPressed() {
if (_drawer.isDrawerOpen(GravityCompat.START)) {
_drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}
public void _play_com() {

@Deprecated
public void showMessage(String _s) {
Toast.makeText(getApplicationContext(), _s,
Toast.LENGTH_SHORT).show();
}

@Deprecated
public int getLocationX(View _v) {
int _location[] = new int[2];
_v.getLocationInWindow(_location);
return _location[0];
}

@Deprecated
public int getLocationY(View _v) {
int _location[] = new int[2];
_v.getLocationInWindow(_location);
return _location[1];
}

@Deprecated
public int getRandom(int _min, int _max) {
Random random = new Random();
return random.nextInt(_max - _min + 1) + _min;
}

@Deprecated
public ArrayList<Double>
getCheckedItemPositionsToArray(ListView _list) {
ArrayList<Double> _result = new ArrayList<Double>();
SparseBooleanArray _arr = _list.getCheckedItemPositions();
for (int _iIdx = 0; _iIdx < _arr.size(); _iIdx++) {
if (_arr.valueAt(_iIdx))
_result.add((double)_arr.keyAt(_iIdx));
}
return _result;
}

@Deprecated
public float getDip(int _input) {
return
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, _input,
getResources().getDisplayMetrics());
}

@Deprecated
public int getDisplayWidthPixels() {
return getResources().getDisplayMetrics().widthPixels;
}

@Deprecated
public int getDisplayHeightPixels() {
return getResources().getDisplayMetrics().heightPixels;
}
}

You might also like