Team Updates

Image in the app: https://images.nasa.gov

hh_2Hana ALalawi
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".DisasterDetails"
android:orientation="vertical"
android:layout_marginTop="20dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/disImg"
android:src="@drawable/ic_launcher_background"
android:layout_gravity="center_horizontal"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:id="@+id/title"
android:textAllCaps="true"
android:layout_gravity="center_horizontal"
android:text="title"
android:textSize="20sp"
android:textStyle="bold"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Discretion"
android:layout_marginRight="20dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:id="@+id/dis"
android:layout_gravity="center_horizontal"
android:textSize="18sp"
android:layout_marginBottom="20dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="200dp"
android:layout_height="100dp"
android:id="@+id/linearbefore"
android:orientation="vertical"
style="@style/textViewStyle"
android:layout_weight="1">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/before"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Before Disaster"
android:id="@+id/before"
android:textAllCaps="true"/>
</LinearLayout>
<LinearLayout
android:layout_width="200dp"
android:layout_height="100dp"
android:id="@+id/linearduring"
android:orientation="vertical"
style="@style/textViewStyle"
android:layout_weight="1">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/during"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="During Disaster"
android:id="@+id/during"
android:textAllCaps="true"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="200dp"
android:layout_height="100dp"
android:id="@+id/linearafter"
android:orientation="vertical"
style="@style/textViewStyle"
android:layout_weight="1">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/after"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="After Disaster"
android:textAllCaps="true" />
</LinearLayout>
<LinearLayout
android:layout_width="200dp"
android:layout_height="100dp"
android:orientation="vertical"
style="@style/textViewStyle"
android:layout_weight="1"
android:id="@+id/lineareme">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/siren"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Emergency calls"
android:id="@+id/after"
android:textAllCaps="true" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
package com.example.hanaalalawi.nasachallenge;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
public class BeforeFragment extends Fragment {
TextView plan1, plan2, plan3, plan4, plan5, plan6, plan7, plan8User, titleB;
ImageView plan1check, plan2check, plan3check, plan4check, plan5check, plan6check, plan7check;
EditText userPlan;
Bundle bundle;
String disTitle;
Button save;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
LayoutInflater lf = getActivity().getLayoutInflater();
View v = lf.inflate(R.layout.activity_before_fragment, container, false);
bundle = getActivity().getIntent().getExtras();
disTitle = bundle.getString("dis_name");
plan1 = (TextView) v.findViewById(R.id.step1);
plan2 = (TextView) v.findViewById(R.id.step2);
plan3 = (TextView) v.findViewById(R.id.step3);
plan4 = (TextView) v.findViewById(R.id.step4);
plan5 = (TextView) v.findViewById(R.id.step5);
plan6 = (TextView) v.findViewById(R.id.step6);
plan7 = (TextView) v.findViewById(R.id.step7);
titleB = (TextView) v.findViewById(R.id.title);
plan8User = (TextView) v.findViewById(R.id.userPlanResult);
userPlan = (EditText) v.findViewById(R.id.userPlan);
save = (Button) v.findViewById(R.id.save);
plan1check = (ImageView) v.findViewById(R.id.circle1);
plan2check = (ImageView) v.findViewById(R.id.circle2);
plan3check = (ImageView) v.findViewById(R.id.circle3);
plan4check = (ImageView) v.findViewById(R.id.circle4);
plan5check = (ImageView) v.findViewById(R.id.circle5);
plan6check = (ImageView) v.findViewById(R.id.circle6);
plan7check = (ImageView) v.findViewById(R.id.circle7);
plan8User.setVisibility(View.GONE);
titleB.setText(disTitle);
if (disTitle.equals("Earthquakes")) {
plan1.setText(R.string.beforeep1);
plan2.setText(R.string.beforeep2);
plan3.setText(R.string.beforeep3);
plan4.setText(R.string.beforeep4);
plan5.setText(R.string.beforeep5);
plan6.setText(R.string.beforeep6);
plan7.setText(R.string.beforeep7);
plan1check.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
plan1check.setImageResource(R.drawable.circle);
}
});
plan2check.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
plan2check.setImageResource(R.drawable.circle);
}
});
plan3check.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
plan3check.setImageResource(R.drawable.circle);
}
});
plan4check.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
plan4check.setImageResource(R.drawable.circle);
}
});
plan5check.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
plan5check.setImageResource(R.drawable.circle);
}
});
plan6check.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
plan6check.setImageResource(R.drawable.circle);
}
});
plan7check.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
plan7check.setImageResource(R.drawable.circle);
}
});
save.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String userplanstr = userPlan.getText().toString();
plan8User.setText(userplanstr);
plan8User.setVisibility(View.VISIBLE);
}
});
}
return v;
}
}
package com.example.hanaalalawi.nasachallenge;
import android.Manifest;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
public class DisasterDetails extends AppCompatActivity {
TextView disDescription, beforeDis, afterDis, duringDis, title;
ImageView disImage;
Bundle bundle;
LinearLayout linearbefore, linearAfter, linearDuring, linearEme;
String discerption, disTitle;
String img;
@SuppressLint("SetTextI18n")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_disaster_details);
disDescription = (TextView) findViewById(R.id.dis);
beforeDis = (TextView) findViewById(R.id.before);
afterDis = (TextView) findViewById(R.id.after);
duringDis = (TextView) findViewById(R.id.during);
disImage = (ImageView) findViewById(R.id.disImg);
title = (TextView) findViewById(R.id.title);
linearbefore = (LinearLayout) findViewById(R.id.linearbefore);
linearAfter = (LinearLayout) findViewById(R.id.linearafter);
linearDuring = (LinearLayout) findViewById(R.id.linearduring);
linearEme = (LinearLayout) findViewById(R.id.lineareme);
bundle = getIntent().getExtras();
disTitle = bundle.getString("dis_name");
img = bundle.getString("dis_img");
title.setText(disTitle);
disImage.setImageResource(Integer.parseInt(img));
beforeDis.setText("Before " + disTitle);
duringDis.setText("During " + disTitle);
afterDis.setText("After " + disTitle);
if (disTitle.equals("Earthquakes")) {
disDescription.setText(R.string.earthquake);
linearbefore.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String name = disTitle;
Intent before = new Intent(DisasterDetails.this, PrepreationActivity.class);
Bundle bundle = new Bundle();
bundle.putString("dis_name", name);
before.putExtras(bundle);
before.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);//clear all activities before the signin
startActivity(before);
}
});
linearEme.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String name = disTitle;
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + "911"));
if (ActivityCompat.checkSelfPermission(DisasterDetails.this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
return;
}
startActivity(intent);
}
});
linearAfter.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String name = disTitle;
Intent before = new Intent(DisasterDetails.this,PrepreationActivity.class);
Bundle bundle = new Bundle();
bundle.putString("dis_name", name);
before.putExtras(bundle);
before.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);//clear all activities before the signin
startActivity(before);
}
});
linearDuring.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String name = disTitle;
Intent before = new Intent(DisasterDetails.this,PrepreationActivity.class);
Bundle bundle = new Bundle();
bundle.putString("dis_name", name);
before.putExtras(bundle);
before.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);//clear all activities before the signin
startActivity(before);
}
});
}else if(disTitle.equals("Fires")){
disDescription.setText(R.string.fire);
}else if(disTitle.equals("Floods")){
disDescription.setText(R.string.flood);
}else if(disTitle.equals("Hurricane")){
disDescription.setText(R.string.Hurricane);
}else if(disTitle.equals("Volcano")){
disDescription.setText(R.string.Volcano);
}
}
}
package com.example.hanaalalawi.nasachallenge;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Rect;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.TypedValue;
import android.view.View;
import android.widget.ImageView;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity {
private RecyclerView recyclerView;
private DisasterAdapter adapter;
private List<Disaster> disList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
disList = new ArrayList<>();
adapter = new DisasterAdapter(this, disList);
RecyclerView.LayoutManager mLayoutManager = new GridLayoutManager(this, 1);
recyclerView.setLayoutManager(mLayoutManager);
recyclerView.addItemDecoration(new GridSpacingItemDecoration(2, dpToPx(10), true));
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setAdapter(adapter);
disastersList();
}
private void disastersList() {
int[] Disasters = new int[]{
R.drawable.earthquake,
R.drawable.fires,
R.drawable.flood,
R.drawable.horicano,
R.drawable.volcano};
Disaster disaster = new Disaster("Earthquakes", Disasters[0]);
disList.add(disaster);
disaster = new Disaster("Fires", Disasters[1]);
disList.add(disaster);
disaster = new Disaster("Floods", Disasters[2]);
disList.add(disaster);
disaster = new Disaster("Hurricane", Disasters[3]);
disList.add(disaster);
disaster = new Disaster("Volcano", Disasters[4]);
disList.add(disaster);
adapter.notifyDataSetChanged();
}
public class GridSpacingItemDecoration extends RecyclerView.ItemDecoration {
private int spanCount;
private int spacing;
private boolean includeEdge;
public GridSpacingItemDecoration(int spanCount, int spacing, boolean includeEdge) {
this.spanCount = spanCount;
this.spacing = spacing;
this.includeEdge = includeEdge;
}
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
int position = parent.getChildAdapterPosition(view);
int column = position % spanCount;
if (includeEdge) {
outRect.left = spacing - column * spacing / spanCount;
outRect.right = (column + 1) * spacing / spanCount;
if (position < spanCount) {
outRect.top = spacing;
}
outRect.bottom = spacing;
} else {
outRect.left = column * spacing / spanCount;
outRect.right = spacing - (column + 1) * spacing / spanCount;
if (position >= spanCount) {
outRect.top = spacing;
}
}
}
}
private int dpToPx(int dp) {
Resources r = getResources();
return Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics()));
}
}
package com.example.hanaalalawi.nasachallenge;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MenuItem;
public class PrepreationActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_prepreation);
BottomNavigationView bottomNavigationView = findViewById(R.id.bottobNavigation);
bottomNavigationView.setOnNavigationItemSelectedListener(navList);
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_place,new BeforeFragment()).commit();
}
private BottomNavigationView.OnNavigationItemSelectedListener navList =
new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
Fragment selectedFragment = null;
switch (item.getItemId()){
case R.id.nav_before:
selectedFragment = new BeforeFragment();
break;
case R.id.nav_during:
selectedFragment = new DuringFragment();
break;
case R.id.nav_after:
selectedFragment = new AfterFragment();
break;
}
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_place,selectedFragment).commit();
return true;
}
};
}
hh_2Hana ALalawi
NASA Logo

SpaceApps is a NASA incubator innovation program.