This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends BaseActivity implements RecyclerItemClickListener.OnItemClickListener { | |
public static final int FROM_LOCAL = 0; | |
public static final int FROM_NET = 1; | |
@InjectView(R.id.recyclerview) | |
RecyclerView recyclerView; | |
@InjectView(R.id.emptytext) | |
TextView emptyText; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void readDataFromDb() { | |
if (locationModels.size() > 0) | |
locationModels.clear(); | |
RealmResults<LocationModel> result = realm | |
.where(LocationModel.class) | |
.findAll(); | |
// sortiny by id. | |
// show greater first | |
result.sort("id", RealmResults.SORT_ORDER_DESCENDING); | |
for (LocationModel data : result) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onItemClick(View v, int position) { | |
Toast.makeText(this, "" + locationModels.get(position).getTujuan(), Toast.LENGTH_SHORT).show(); | |
Bundle data = new Bundle(); | |
data.putInt("status", FROM_LOCAL); | |
data.putString("id", locationModels.get(position).getId()); | |
startActivity(new Intent(this, ViewRouteActivity.class).putExtras(data)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = getIntent().getExtras(); | |
if (data.getInt("status") == MainActivity.FROM_LOCAL) { | |
// baca db | |
latLngList = readDataFromDB(data.getString("id")); | |
// draw | |
drawDirectionToMap(latLngList); | |
} else { | |
latAwal = data.getDouble("latAwal"); | |
lngAwal = data.getDouble("lngAwal"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private List<LatLng> readDataFromDB(String id) { | |
RealmResults<LocationModel> result = realm.where(LocationModel.class).equalTo("id", id).findAll(); | |
List<LatLng> listlatlng = new ArrayList<>(); | |
for (LatLngModel data : result.get(0).getLatLngRealmList()) | |
listlatlng.add(new LatLng(data.getLat(), data.getLng())); | |
return listlatlng; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.support.v7.widget.LinearLayoutManager; | |
import android.support.v7.widget.RecyclerView; | |
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener { | |
public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName(); | |
private int previousTotal = 0; // The total number of items in the dataset after the last load | |
private boolean loading = true; // True if we are still waiting for the last set of data to load. | |
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more. | |
int firstVisibleItem, visibleItemCount, totalItemCount; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class UtilsLog{ | |
public static void DEBUG(String message){ | |
if(BuildConfig.DEBUG){ | |
Log.d("debug",message); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<android.support.v4.widget.DrawerLayout 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:id="@+id/drawerLayout" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:fitsSystemWindows="true" | |
tools:context=".MainActivity"> | |
<!-- content--> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<menu xmlns:android="http://schemas.android.com/apk/res/android"> | |
<group android:checkableBehavior="single"> | |
<item | |
android:id="@+id/nav_home" | |
android:icon="@drawable/ic_home" | |
android:title="Home" /> | |
<item | |
android:id="@+id/nav_contact" |