Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Budi Oktaviyan budioktaviyan

🏠
Working from home
View GitHub Profile
View App.kt
package id.kotlin.situng
import org.apache.commons.io.FileUtils
import org.openqa.selenium.OutputType
import org.openqa.selenium.TakesScreenshot
import org.openqa.selenium.chrome.ChromeDriver
import java.io.File
import java.text.SimpleDateFormat
import java.util.Date
View item_home.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:padding="8dp">
<ImageView
android:id="@+id/iv_home"
@budioktaviyan
budioktaviyan / HomeFragment.java
Created Dec 27, 2016
Home Fragment Class (Cont'd)
View HomeFragment.java
public class HomeFragment extends Fragment {
@Override
public void onActivityCreated(@Nullable final Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
// Prepare mock object into list of items
final List<String> items = new ArrayList<>();
items.add("Opsi Satu");
items.add("Opsi Dua");
@budioktaviyan
budioktaviyan / HomeFragment.java
Created Dec 27, 2016
Home Fragment Class (Cont'd)
View HomeFragment.java
public class HomeFragment extends Fragment {
@Override
public void onActivityCreated(@Nullable final Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
final RecyclerView recyclerView = (RecyclerView) getActivity().findViewById(R.id.rv_home);
final LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
final HomeAdapter homeAdapter = new HomeAdapter(items);
recyclerView.setLayoutManager(linearLayoutManager);
@budioktaviyan
budioktaviyan / HomeAdapter.java
Last active Dec 27, 2016
Home Adapter Class
View HomeAdapter.java
public class HomeAdapter extends RecyclerView.Adapter<HomeAdapter.HomeHolder> {
private final List<String> mItems;
public HomeAdapter(final List<String> items) {
mItems = items;
}
@Override
public HomeHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
final View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_home, parent, false);
View fragment_home.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_home"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical" />
View item_home.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp">
<ImageView
android:id="@+id/iv_home"
android:layout_width="48dp"
android:layout_height="48dp"
@budioktaviyan
budioktaviyan / MainActivity.java
Last active Dec 26, 2016
Main Activity Class (Cont'd)
View MainActivity.java
public class MainActivity extends AppCompatActivity {
MenuItem mMenuItem;
DrawerLayout mDrawerLayout;
private ActionBarDrawerToggle mActionBarDrawerToggle;
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
mDrawerLayout = (DrawerLayout) findViewById(R.id.dl_main);
final NavigationView navigationView = (NavigationView) findViewById(R.id.nv_main);
View activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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"
tools:context="com.baculsoft.belajarandroid.views.activities.MainActivity"
tools:targetApi="LOLLIPOP">
<android.support.v4.widget.DrawerLayout
View DetailFragment.java
public class DetailFragment extends Fragment {
@Nullable
@Override
public View onCreateView(final LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable final Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_detail, container, false);
}
}