├── a.jks ├── app ├── .gitignore ├── app-release.apk ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── id │ │ └── co │ │ └── imastudio │ │ └── santri │ │ └── jogjatourismplace │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── id │ │ │ └── co │ │ │ └── imastudio │ │ │ └── santri │ │ │ └── jogjatourismplace │ │ │ ├── ErrorActivity.java │ │ │ ├── ListWisata.java │ │ │ ├── Login.java │ │ │ ├── SingleItemView.java │ │ │ ├── Splash.java │ │ │ └── adapter │ │ │ ├── FileCache.java │ │ │ ├── ImageLoader.java │ │ │ ├── JSONfunctions.java │ │ │ ├── ListViewAdapter.java │ │ │ ├── MemoryCache.java │ │ │ └── Utils.java │ └── res │ │ ├── drawable-v21 │ │ ├── ic_menu_camera.xml │ │ ├── ic_menu_gallery.xml │ │ ├── ic_menu_manage.xml │ │ ├── ic_menu_send.xml │ │ ├── ic_menu_share.xml │ │ └── ic_menu_slideshow.xml │ │ ├── drawable │ │ ├── jogjaicon.png │ │ ├── side_nav_bar.xml │ │ └── temp_img.png │ │ ├── layout │ │ ├── activity_error.xml │ │ ├── activity_list_wisata.xml │ │ ├── activity_login.xml │ │ ├── activity_main.xml │ │ ├── activity_single_item_view.xml │ │ ├── activity_splash.xml │ │ ├── app_bar_main.xml │ │ ├── content_main.xml │ │ ├── layout_listview.xml │ │ ├── listview_item.xml │ │ └── nav_header_main.xml │ │ ├── menu │ │ ├── activity_main_drawer.xml │ │ └── main.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_round.png │ │ └── jogjaicon.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_round.png │ │ └── jogjaicon.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── drawables.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── id │ └── co │ └── imastudio │ └── santri │ └── jogjatourismplace │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── jogjaToursim.jks └── settings.gradle /a.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basriumar12/hacktoberFest/7648bdfb651429dad667b86c005314305f7fdb4b/a.jks -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/app-release.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basriumar12/hacktoberFest/7648bdfb651429dad667b86c005314305f7fdb4b/app/app-release.apk -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.0" 6 | defaultConfig { 7 | applicationId "id.co.imastudio.santri.jogjatourismplace" 8 | minSdkVersion 15 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | 21 | useLibrary 'org.apache.http.legacy' 22 | } 23 | 24 | dependencies { 25 | compile fileTree(dir: 'libs', include: ['*.jar']) 26 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 27 | exclude group: 'com.android.support', module: 'support-annotations' 28 | }) 29 | compile 'com.android.support:appcompat-v7:25.3.1' 30 | compile 'com.android.support:cardview-v7:25.3.1' 31 | compile 'com.android.support:design:25.3.1' 32 | compile 'com.android.support.constraint:constraint-layout:1.0.2' 33 | testCompile 'junit:junit:4.12' 34 | } 35 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\Users\Server\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /app/src/androidTest/java/id/co/imastudio/santri/jogjatourismplace/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package id.co.imastudio.santri.jogjatourismplace; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("id.co.imastudio.santri.jogjatourismplace", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 21 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 33 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /app/src/main/java/id/co/imastudio/santri/jogjatourismplace/ErrorActivity.java: -------------------------------------------------------------------------------- 1 | package id.co.imastudio.santri.jogjatourismplace; 2 | 3 | import android.content.Context; 4 | import android.net.ConnectivityManager; 5 | import android.net.NetworkInfo; 6 | import android.os.Bundle; 7 | import android.support.v7.app.AppCompatActivity; 8 | import android.view.Menu; 9 | import android.widget.Toast; 10 | 11 | public class ErrorActivity extends AppCompatActivity { 12 | String answer; 13 | @Override 14 | protected void onCreate(Bundle savedInstanceState) { 15 | super.onCreate(savedInstanceState); 16 | setContentView(R.layout.activity_error); 17 | ConnectivityManager cm = (ConnectivityManager) getApplicationContext() 18 | .getSystemService(Context.CONNECTIVITY_SERVICE); 19 | NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); 20 | if (null != activeNetwork) { 21 | if(activeNetwork.getType() == ConnectivityManager.TYPE_WIFI) 22 | answer="You are connected to a WiFi Network"; 23 | if(activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) 24 | answer="You are connected to a Mobile Network"; 25 | } 26 | else 27 | answer = "No internet Connectivity"; 28 | Toast.makeText(getApplicationContext(), answer, Toast.LENGTH_LONG).show(); 29 | } 30 | 31 | @Override 32 | public boolean onCreateOptionsMenu(Menu menu) { 33 | // Inflate the menu; this adds items to the action bar if it is present. 34 | getMenuInflater().inflate(R.menu.main, menu); 35 | return true; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/java/id/co/imastudio/santri/jogjatourismplace/ListWisata.java: -------------------------------------------------------------------------------- 1 | package id.co.imastudio.santri.jogjatourismplace; 2 | 3 | import android.app.ProgressDialog; 4 | import android.os.AsyncTask; 5 | import android.os.Bundle; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.util.Log; 8 | import android.widget.ListView; 9 | 10 | import org.json.JSONArray; 11 | import org.json.JSONException; 12 | import org.json.JSONObject; 13 | 14 | import java.util.ArrayList; 15 | import java.util.HashMap; 16 | 17 | import id.co.imastudio.santri.jogjatourismplace.adapter.JSONfunctions; 18 | import id.co.imastudio.santri.jogjatourismplace.adapter.ListViewAdapter; 19 | 20 | public class ListWisata extends AppCompatActivity { 21 | // Declare Variables 22 | JSONObject jsonobject; 23 | JSONArray jsonarray; 24 | ListView listview; 25 | ListViewAdapter adapter; 26 | ProgressDialog mProgressDialog; 27 | ArrayList> arraylist; 28 | public static String JUDUL = "nama_pariwisata"; 29 | public static String ALMAT = "alamat_pariwisata"; 30 | public static String DETAIL = "detail_pariwisata"; 31 | public static String GAMBAR = "gambar_pariwisata"; 32 | 33 | @Override 34 | public void onCreate(Bundle savedInstanceState) { 35 | super.onCreate(savedInstanceState); 36 | // Get the view from listview_main.xml 37 | setContentView(R.layout.activity_list_wisata); 38 | /* Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 39 | setSupportActionBar(toolbar);*/ 40 | // Execute DownloadJSON AsyncTask 41 | 42 | new DownloadJSON().execute(); 43 | } 44 | 45 | 46 | // DownloadJSON AsyncTask 47 | public class DownloadJSON extends AsyncTask { 48 | @Override 49 | protected void onPreExecute() { 50 | super.onPreExecute(); 51 | // Create a progressdialog 52 | mProgressDialog = new ProgressDialog(ListWisata.this); 53 | // Set progressdialog title 54 | mProgressDialog.setTitle("Ambil Data Dari Server"); 55 | // Set progressdialog message 56 | mProgressDialog.setMessage("Sabar Ya . . ."); 57 | mProgressDialog.setIndeterminate(false); 58 | // Show progressdialog 59 | mProgressDialog.show(); 60 | } 61 | 62 | 63 | @Override 64 | protected Void doInBackground(Void... params) { 65 | // Create an array 66 | arraylist = new ArrayList>(); 67 | // Retrieve JSON Objects from the given URL address 68 | jsonobject = JSONfunctions 69 | .getJSONfromURL("http://www.erporate.com/bootcamp/jsonBootcamp.php"); 70 | 71 | try { 72 | // Locate the array name in JSON 73 | jsonarray = jsonobject.getJSONArray("data"); 74 | 75 | for (int i = 0; i < jsonarray.length(); i++) { 76 | HashMap map = new HashMap(); 77 | jsonobject = jsonarray.getJSONObject(i); 78 | // Retrive JSON Objects 79 | map.put("nama_pariwisata", jsonobject.getString("nama_pariwisata")); 80 | map.put("alamat_pariwisata", jsonobject.getString("alamat_pariwisata")); 81 | map.put("detail_pariwisata", jsonobject.getString("detail_pariwisata")); 82 | map.put("gambar_pariwisata", jsonobject.getString("gambar_pariwisata")); 83 | // Set the JSON Objects into the array 84 | arraylist.add(map); 85 | } 86 | } catch (JSONException e) { 87 | Log.e("Error", e.getMessage()); 88 | e.printStackTrace(); 89 | } 90 | return null; 91 | } 92 | 93 | @Override 94 | protected void onPostExecute(Void args) { 95 | // Locate the listview in listview_main.xml 96 | listview = (ListView) findViewById(R.id.listview); 97 | // Pass the results into ListViewAdapter.java 98 | adapter = new ListViewAdapter(ListWisata.this, arraylist); 99 | // Set the adapter to the ListView 100 | listview.setAdapter(adapter); 101 | // Close the progressdialog 102 | mProgressDialog.dismiss(); 103 | } 104 | } 105 | @Override 106 | public void onBackPressed() { 107 | 108 | finish(); 109 | 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /app/src/main/java/id/co/imastudio/santri/jogjatourismplace/Login.java: -------------------------------------------------------------------------------- 1 | package id.co.imastudio.santri.jogjatourismplace; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.view.View; 7 | import android.widget.EditText; 8 | import android.widget.Toast; 9 | 10 | public class Login extends AppCompatActivity { 11 | EditText editText1 ,editText2; //Deklarasi object dari class EdiText 12 | String text1 ,text2; //Deklarasi object string 13 | 14 | @Override 15 | protected void onCreate(Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | setContentView(R.layout.activity_login); 18 | 19 | } 20 | public void loginMasuk(View view) { 21 | //Method onClick pada Button 22 | 23 | editText1 = (EditText)findViewById(R.id.edittext_username); 24 | editText2 = (EditText) findViewById(R.id.edittext_password); 25 | text1 = editText1.getText().toString(); 26 | text2 = editText2.getText().toString(); 27 | 28 | if ((text1.contains("Username"))&&((text2.contains("Password")))) { 29 | Toast.makeText(this, "Sukses Login", Toast.LENGTH_SHORT).show(); 30 | Intent intent = new Intent(Login.this, Splash.class); 31 | startActivity(intent); 32 | } 33 | 34 | else if ((text1.matches("")||text2.matches(""))) 35 | { 36 | //Maka akan menampilkan pesan text toast 37 | Toast.makeText(this, "Isikan Username dan Password", Toast.LENGTH_SHORT).show(); 38 | 39 | } 40 | 41 | else { 42 | //jika kedua kondisi diatas tidak memenuhi 43 | 44 | Toast.makeText(this, "Login Gagal /Username Password Salah", Toast.LENGTH_SHORT).show(); 45 | } 46 | 47 | } 48 | @Override 49 | public void onBackPressed() { 50 | finish(); 51 | 52 | 53 | } 54 | 55 | 56 | public void backSession() { 57 | backThisPage(); 58 | 59 | } 60 | 61 | 62 | } 63 | 64 | -------------------------------------------------------------------------------- /app/src/main/java/id/co/imastudio/santri/jogjatourismplace/SingleItemView.java: -------------------------------------------------------------------------------- 1 | package id.co.imastudio.santri.jogjatourismplace; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.support.v7.widget.Toolbar; 7 | import android.view.MenuItem; 8 | import android.view.Window; 9 | import android.widget.ImageView; 10 | import android.widget.TextView; 11 | 12 | import id.co.imastudio.santri.jogjatourismplace.adapter.ImageLoader; 13 | 14 | public class SingleItemView extends AppCompatActivity { 15 | 16 | // Declare Variables 17 | String judul; 18 | String alamat; 19 | String detail; 20 | String gambar; 21 | String position; 22 | ImageLoader imageLoader = new ImageLoader(this); 23 | private Toolbar toolbar; 24 | @Override 25 | public void onCreate(Bundle savedInstanceState) { 26 | super.onCreate(savedInstanceState); 27 | this.requestWindowFeature(Window.FEATURE_NO_TITLE); 28 | // Get the view from singleitemview.xml 29 | setContentView(R.layout.activity_single_item_view); 30 | 31 | Intent i = getIntent(); 32 | 33 | judul = i.getStringExtra("judul"); 34 | 35 | alamat = i.getStringExtra("alamat"); 36 | 37 | detail = i.getStringExtra("detail"); 38 | 39 | gambar = i.getStringExtra("gambar"); 40 | 41 | // Locate the TextViews in singleitemview.xml 42 | TextView judulSi = (TextView) findViewById(R.id.judulSi); 43 | TextView alamatSI = (TextView) findViewById(R.id.alamatSi); 44 | TextView detailSi = (TextView) findViewById(R.id.detailSi); 45 | 46 | // Locate the ImageView in singleitemview.xml 47 | ImageView imgflag = (ImageView) findViewById(R.id.imgflag); 48 | 49 | // Set results to the TextViews 50 | judulSi.setText(judul); 51 | alamatSI.setText(alamat); 52 | detailSi.setText(detail); 53 | 54 | imageLoader.DisplayImage(gambar, imgflag); 55 | // get position 56 | imageLoader.DisplayImage(gambar, position); 57 | } 58 | 59 | @Override 60 | public boolean onOptionsItemSelected(MenuItem item) { 61 | int id = item.getItemId(); 62 | 63 | //noinspection SimplifiableIfStatement 64 | if (id == android.R.id.home) { 65 | onBackPressed(); 66 | return true; 67 | } 68 | return super.onOptionsItemSelected(item); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /app/src/main/java/id/co/imastudio/santri/jogjatourismplace/Splash.java: -------------------------------------------------------------------------------- 1 | package id.co.imastudio.santri.jogjatourismplace; 2 | 3 | import android.app.AlertDialog; 4 | import android.content.Context; 5 | import android.content.DialogInterface; 6 | import android.content.Intent; 7 | import android.content.pm.ActivityInfo; 8 | import android.net.ConnectivityManager; 9 | import android.net.NetworkInfo; 10 | import android.os.Bundle; 11 | import android.support.v7.app.AppCompatActivity; 12 | 13 | public class Splash extends AppCompatActivity { 14 | String answer; 15 | 16 | 17 | @Override 18 | protected void onCreate(Bundle savedInstanceState) { 19 | super.onCreate(savedInstanceState); 20 | setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); 21 | setContentView(R.layout.activity_splash); 22 | 23 | if (isWorkingInternetPersent()) { 24 | splash(); 25 | } else { 26 | showAlertDialog(Splash.this, "Tidak ada Koneksi Internet", 27 | "Nyalakan Wifi / Paket Data", false); 28 | } 29 | } 30 | 31 | public void splash() { 32 | Thread timerTread = new Thread() { 33 | public void run() { 34 | try { 35 | sleep(3000); 36 | } catch (InterruptedException e) { 37 | e.printStackTrace(); 38 | } finally { 39 | Intent intent = new Intent(getApplicationContext(), ListWisata.class); 40 | intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); 41 | startActivity(intent); 42 | finish(); 43 | } 44 | } 45 | }; 46 | timerTread.start(); 47 | } 48 | 49 | public boolean isWorkingInternetPersent() { 50 | ConnectivityManager connectivityManager = (ConnectivityManager) getBaseContext() 51 | .getSystemService(Context.CONNECTIVITY_SERVICE); 52 | if (connectivityManager != null) { 53 | NetworkInfo[] info = connectivityManager.getAllNetworkInfo(); 54 | if (info != null) 55 | for (int i = 0; i < info.length; i++) 56 | if (info[i].getState() == NetworkInfo.State.CONNECTED) { 57 | return true; 58 | } 59 | 60 | } 61 | return false; 62 | } 63 | 64 | public void showAlertDialog(Context context, String title, String message, Boolean status) { 65 | AlertDialog alertDialog = new AlertDialog.Builder(context).create(); 66 | 67 | // Setting Dialog Title 68 | alertDialog.setTitle(title); 69 | 70 | // Setting Dialog Message 71 | alertDialog.setMessage(message); 72 | 73 | // Setting alert dialog icon 74 | // alertDialog.setIcon((status) ? R.mipmap.ic_launcher : R.mipmap.ic_launcher); 75 | 76 | // Setting OK Button 77 | alertDialog.setButton("OK", new DialogInterface.OnClickListener() { 78 | public void onClick(DialogInterface dialog, int which) { 79 | 80 | finish(); 81 | System.exit(0); 82 | } 83 | }); 84 | 85 | // Showing Alert Message 86 | alertDialog.show(); 87 | } 88 | @Override 89 | public void onBackPressed() { 90 | finish(); 91 | 92 | 93 | } 94 | 95 | } 96 | /* 97 | 98 | @Override 99 | protected void onCreate(Bundle savedInstanceState) { 100 | super.onCreate(savedInstanceState); 101 | setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); 102 | setContentView(R.layout.activity_splash); 103 | 104 | new Handler().postDelayed(new Runnable() { 105 | @Override 106 | public void run() { 107 | //TODO Auto-generated method stub 108 | if(isOnline()) { 109 | 110 | Intent i = new Intent(Splash.this, ListWisata.class); 111 | startActivity(i); 112 | //jeda selesai Splashscreen 113 | this.finish(); 114 | // INTERNET AVAILABLE 115 | } else { 116 | Intent i = new Intent(Splash.this, ErrorActivity.class); 117 | startActivity(i); 118 | //jeda selesai Splashscreen 119 | this.finish(); 120 | 121 | 122 | }} 123 | 124 | private void finish() { 125 | // TODO Auto-generated method stub 126 | } 127 | }, 3000); 128 | } 129 | 130 | public boolean isOnline() { 131 | ConnectivityManager cm = (ConnectivityManager) getApplicationContext() 132 | .getSystemService(Context.CONNECTIVITY_SERVICE); 133 | NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); 134 | if (null != activeNetwork) { 135 | if(activeNetwork.getType() == ConnectivityManager.TYPE_WIFI) 136 | answer="You are connected to a WiFi Network"; 137 | if(activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) 138 | answer="You are connected to a Mobile Network"; 139 | } 140 | return false; 141 | 142 | } 143 | 144 | } 145 | */ 146 | -------------------------------------------------------------------------------- /app/src/main/java/id/co/imastudio/santri/jogjatourismplace/adapter/FileCache.java: -------------------------------------------------------------------------------- 1 | package id.co.imastudio.santri.jogjatourismplace.adapter; 2 | 3 | import android.content.Context; 4 | 5 | import java.io.File; 6 | 7 | public class FileCache { 8 | 9 | private File cacheDir; 10 | 11 | public FileCache(Context context) { 12 | // Find the dir to save cached images 13 | if (android.os.Environment.getExternalStorageState().equals( 14 | android.os.Environment.MEDIA_MOUNTED)) 15 | cacheDir = new File( 16 | android.os.Environment.getExternalStorageDirectory(), 17 | "JsonParseTutorialCache"); 18 | else 19 | cacheDir = context.getCacheDir(); 20 | if (!cacheDir.exists()) 21 | cacheDir.mkdirs(); 22 | } 23 | 24 | public File getFile(String url) { 25 | String filename = String.valueOf(url.hashCode()); 26 | // String filename = URLEncoder.encode(url); 27 | File f = new File(cacheDir, filename); 28 | return f; 29 | 30 | } 31 | 32 | public void clear() { 33 | File[] files = cacheDir.listFiles(); 34 | if (files == null) 35 | return; 36 | for (File f : files) 37 | f.delete(); 38 | } 39 | 40 | } -------------------------------------------------------------------------------- /app/src/main/java/id/co/imastudio/santri/jogjatourismplace/adapter/ImageLoader.java: -------------------------------------------------------------------------------- 1 | package id.co.imastudio.santri.jogjatourismplace.adapter; 2 | 3 | import android.content.Context; 4 | import android.graphics.Bitmap; 5 | import android.graphics.BitmapFactory; 6 | import android.os.Handler; 7 | import android.widget.ImageView; 8 | 9 | import java.io.File; 10 | import java.io.FileInputStream; 11 | import java.io.FileNotFoundException; 12 | import java.io.FileOutputStream; 13 | import java.io.IOException; 14 | import java.io.InputStream; 15 | import java.io.OutputStream; 16 | import java.net.HttpURLConnection; 17 | import java.net.URL; 18 | import java.util.Collections; 19 | import java.util.Map; 20 | import java.util.WeakHashMap; 21 | import java.util.concurrent.ExecutorService; 22 | import java.util.concurrent.Executors; 23 | 24 | import id.co.imastudio.santri.jogjatourismplace.R; 25 | 26 | public class ImageLoader { 27 | 28 | MemoryCache memoryCache = new MemoryCache(); 29 | FileCache fileCache; 30 | private Map imageViews = Collections 31 | .synchronizedMap(new WeakHashMap()); 32 | ExecutorService executorService; 33 | // Handler to display images in UI thread 34 | Handler handler = new Handler(); 35 | 36 | public ImageLoader(Context context) { 37 | fileCache = new FileCache(context); 38 | executorService = Executors.newFixedThreadPool(5); 39 | } 40 | 41 | final int stub_id = R.drawable.temp_img; 42 | 43 | public void DisplayImage(String url, ImageView imageView) { 44 | imageViews.put(imageView, url); 45 | Bitmap bitmap = memoryCache.get(url); 46 | if (bitmap != null) 47 | imageView.setImageBitmap(bitmap); 48 | else { 49 | queuePhoto(url, imageView); 50 | imageView.setImageResource(stub_id); 51 | } 52 | } 53 | 54 | private void queuePhoto(String url, ImageView imageView) { 55 | PhotoToLoad p = new PhotoToLoad(url, imageView); 56 | executorService.submit(new PhotosLoader(p)); 57 | } 58 | 59 | private Bitmap getBitmap(String url) { 60 | File f = fileCache.getFile(url); 61 | 62 | Bitmap b = decodeFile(f); 63 | if (b != null) 64 | return b; 65 | 66 | // Download Images from the Internet 67 | try { 68 | Bitmap bitmap = null; 69 | URL imageUrl = new URL(url); 70 | HttpURLConnection conn = (HttpURLConnection) imageUrl 71 | .openConnection(); 72 | conn.setConnectTimeout(30000); 73 | conn.setReadTimeout(30000); 74 | conn.setInstanceFollowRedirects(true); 75 | InputStream is = conn.getInputStream(); 76 | OutputStream os = new FileOutputStream(f); 77 | Utils.CopyStream(is, os); 78 | os.close(); 79 | conn.disconnect(); 80 | bitmap = decodeFile(f); 81 | return bitmap; 82 | } catch (Throwable ex) { 83 | ex.printStackTrace(); 84 | if (ex instanceof OutOfMemoryError) 85 | memoryCache.clear(); 86 | return null; 87 | } 88 | } 89 | 90 | // Decodes image and scales it to reduce memory consumption 91 | private Bitmap decodeFile(File f) { 92 | try { 93 | // Decode image size 94 | BitmapFactory.Options o = new BitmapFactory.Options(); 95 | o.inJustDecodeBounds = true; 96 | FileInputStream stream1 = new FileInputStream(f); 97 | BitmapFactory.decodeStream(stream1, null, o); 98 | stream1.close(); 99 | 100 | // Find the correct scale value. It should be the power of 2. 101 | // Recommended Size 512 102 | final int REQUIRED_SIZE = 70; 103 | int width_tmp = o.outWidth, height_tmp = o.outHeight; 104 | int scale = 1; 105 | while (true) { 106 | if (width_tmp / 2 < REQUIRED_SIZE 107 | || height_tmp / 2 < REQUIRED_SIZE) 108 | break; 109 | width_tmp /= 2; 110 | height_tmp /= 2; 111 | scale *= 2; 112 | } 113 | 114 | // Decode with inSampleSize 115 | BitmapFactory.Options o2 = new BitmapFactory.Options(); 116 | o2.inSampleSize = scale; 117 | FileInputStream stream2 = new FileInputStream(f); 118 | Bitmap bitmap = BitmapFactory.decodeStream(stream2, null, o2); 119 | stream2.close(); 120 | return bitmap; 121 | } catch (FileNotFoundException e) { 122 | } catch (IOException e) { 123 | e.printStackTrace(); 124 | } 125 | return null; 126 | } 127 | 128 | // Task for the queue 129 | private class PhotoToLoad { 130 | public String url; 131 | public ImageView imageView; 132 | 133 | public PhotoToLoad(String u, ImageView i) { 134 | url = u; 135 | imageView = i; 136 | } 137 | } 138 | 139 | class PhotosLoader implements Runnable { 140 | PhotoToLoad photoToLoad; 141 | 142 | PhotosLoader(PhotoToLoad photoToLoad) { 143 | this.photoToLoad = photoToLoad; 144 | } 145 | 146 | @Override 147 | public void run() { 148 | try { 149 | if (imageViewReused(photoToLoad)) 150 | return; 151 | Bitmap bmp = getBitmap(photoToLoad.url); 152 | memoryCache.put(photoToLoad.url, bmp); 153 | if (imageViewReused(photoToLoad)) 154 | return; 155 | BitmapDisplayer bd = new BitmapDisplayer(bmp, photoToLoad); 156 | handler.post(bd); 157 | } catch (Throwable th) { 158 | th.printStackTrace(); 159 | } 160 | } 161 | } 162 | 163 | boolean imageViewReused(PhotoToLoad photoToLoad) { 164 | String tag = imageViews.get(photoToLoad.imageView); 165 | if (tag == null || !tag.equals(photoToLoad.url)) 166 | return true; 167 | return false; 168 | } 169 | 170 | // Used to display bitmap in the UI thread 171 | class BitmapDisplayer implements Runnable { 172 | Bitmap bitmap; 173 | PhotoToLoad photoToLoad; 174 | 175 | public BitmapDisplayer(Bitmap b, PhotoToLoad p) { 176 | bitmap = b; 177 | photoToLoad = p; 178 | } 179 | 180 | public void run() { 181 | if (imageViewReused(photoToLoad)) 182 | return; 183 | if (bitmap != null) 184 | photoToLoad.imageView.setImageBitmap(bitmap); 185 | else 186 | photoToLoad.imageView.setImageResource(stub_id); 187 | } 188 | } 189 | 190 | public void clearCache() { 191 | memoryCache.clear(); 192 | fileCache.clear(); 193 | } 194 | 195 | } -------------------------------------------------------------------------------- /app/src/main/java/id/co/imastudio/santri/jogjatourismplace/adapter/JSONfunctions.java: -------------------------------------------------------------------------------- 1 | package id.co.imastudio.santri.jogjatourismplace.adapter; 2 | 3 | import android.util.Log; 4 | 5 | import org.apache.http.HttpEntity; 6 | import org.apache.http.HttpResponse; 7 | import org.apache.http.client.HttpClient; 8 | import org.apache.http.client.methods.HttpPost; 9 | import org.apache.http.impl.client.DefaultHttpClient; 10 | import org.json.JSONException; 11 | import org.json.JSONObject; 12 | 13 | import java.io.BufferedReader; 14 | import java.io.InputStream; 15 | import java.io.InputStreamReader; 16 | 17 | public class JSONfunctions { 18 | 19 | public static JSONObject getJSONfromURL(String url) { 20 | InputStream is = null; 21 | String result = ""; 22 | JSONObject jArray = null; 23 | 24 | // Download JSON data from URL 25 | try { 26 | HttpClient httpclient = new DefaultHttpClient(); 27 | HttpPost httppost = new HttpPost(url); 28 | HttpResponse response = httpclient.execute(httppost); 29 | HttpEntity entity = response.getEntity(); 30 | is = entity.getContent(); 31 | 32 | } catch (Exception e) { 33 | Log.e("log_tag", "Error in http connection " + e.toString()); 34 | } 35 | 36 | // Convert response to string 37 | try { 38 | BufferedReader reader = new BufferedReader(new InputStreamReader( 39 | is, "iso-8859-1"), 8); 40 | StringBuilder sb = new StringBuilder(); 41 | String line = null; 42 | while ((line = reader.readLine()) != null) { 43 | sb.append(line + "\n"); 44 | } 45 | is.close(); 46 | result = sb.toString(); 47 | } catch (Exception e) { 48 | Log.e("log_tag", "Error converting result " + e.toString()); 49 | } 50 | 51 | try { 52 | 53 | jArray = new JSONObject(result); 54 | } catch (JSONException e) { 55 | Log.e("log_tag", "Error parsing data " + e.toString()); 56 | } 57 | 58 | return jArray; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /app/src/main/java/id/co/imastudio/santri/jogjatourismplace/adapter/ListViewAdapter.java: -------------------------------------------------------------------------------- 1 | package id.co.imastudio.santri.jogjatourismplace.adapter; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.View.OnClickListener; 8 | import android.view.ViewGroup; 9 | import android.widget.BaseAdapter; 10 | import android.widget.ImageView; 11 | import android.widget.TextView; 12 | 13 | import java.util.ArrayList; 14 | import java.util.HashMap; 15 | 16 | import id.co.imastudio.santri.jogjatourismplace.ListWisata; 17 | import id.co.imastudio.santri.jogjatourismplace.R; 18 | import id.co.imastudio.santri.jogjatourismplace.SingleItemView; 19 | 20 | public class ListViewAdapter extends BaseAdapter { 21 | 22 | // Declare Variables 23 | Context context; 24 | LayoutInflater inflater; 25 | ArrayList> data; 26 | ImageLoader imageLoader; 27 | HashMap resultp = new HashMap(); 28 | 29 | public ListViewAdapter(Context context, 30 | ArrayList> arraylist) { 31 | this.context = context; 32 | data = arraylist; 33 | imageLoader = new ImageLoader(context); 34 | } 35 | 36 | @Override 37 | public int getCount() { 38 | return data.size(); 39 | } 40 | 41 | @Override 42 | public Object getItem(int position) { 43 | return null; 44 | } 45 | 46 | @Override 47 | public long getItemId(int position) { 48 | return 0; 49 | } 50 | 51 | public View getView(final int position, View convertView, ViewGroup parent) { 52 | // Declare Variables 53 | TextView judul; 54 | TextView alamat; 55 | TextView detail; 56 | ImageView gambar; 57 | 58 | inflater = (LayoutInflater) context 59 | .getSystemService(Context.LAYOUT_INFLATER_SERVICE); 60 | 61 | View itemView = inflater.inflate(R.layout.listview_item, parent, false); 62 | // Get the position 63 | resultp = data.get(position); 64 | 65 | // Locate the TextViews in listview_item.xml 66 | judul = (TextView) itemView.findViewById(R.id.judul); 67 | alamat = (TextView) itemView.findViewById(R.id.alamat); 68 | detail = (TextView) itemView.findViewById(R.id.detail); 69 | 70 | // Locate the ImageView in listview_item.xml 71 | gambar = (ImageView) itemView.findViewById(R.id.gambar); 72 | 73 | // Capture position and set results to the TextViews 74 | judul.setText(resultp.get(ListWisata.JUDUL)); 75 | alamat.setText(resultp.get(ListWisata.ALMAT)); 76 | detail.setText(resultp.get(ListWisata.DETAIL)); 77 | // Capture position and set results to the ImageView 78 | // Passes flag images URL into ImageLoader.class 79 | imageLoader.DisplayImage(resultp.get(ListWisata.GAMBAR), gambar); 80 | // Capture ListView item click 81 | itemView.setOnClickListener(new OnClickListener() { 82 | 83 | @Override 84 | public void onClick(View arg0) { 85 | // Get the position 86 | resultp = data.get(position); 87 | Intent intent = new Intent(context, SingleItemView.class); 88 | // Pass all data rank 89 | intent.putExtra("judul", resultp.get(ListWisata.JUDUL)); 90 | // Pass all data country 91 | intent.putExtra("alamat", resultp.get(ListWisata.ALMAT)); 92 | // Pass all data population 93 | intent.putExtra("detail",resultp.get(ListWisata.DETAIL)); 94 | // Pass all data flag 95 | intent.putExtra("gambar", resultp.get(ListWisata.GAMBAR)); 96 | // Start SingleItemView Class 97 | context.startActivity(intent); 98 | 99 | } 100 | }); 101 | return itemView; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /app/src/main/java/id/co/imastudio/santri/jogjatourismplace/adapter/MemoryCache.java: -------------------------------------------------------------------------------- 1 | package id.co.imastudio.santri.jogjatourismplace.adapter; 2 | 3 | import android.graphics.Bitmap; 4 | import android.util.Log; 5 | 6 | import java.util.Collections; 7 | import java.util.Iterator; 8 | import java.util.LinkedHashMap; 9 | import java.util.Map; 10 | import java.util.Map.Entry; 11 | 12 | public class MemoryCache { 13 | 14 | private static final String TAG = "MemoryCache"; 15 | 16 | // Last argument true for LRU ordering 17 | private Map cache = Collections 18 | .synchronizedMap(new LinkedHashMap(10, 1.5f, true)); 19 | 20 | // Current allocated size 21 | private long size = 0; 22 | 23 | // Max memory in bytes 24 | private long limit = 1000000; 25 | 26 | public MemoryCache() { 27 | // Use 25% of available heap size 28 | setLimit(Runtime.getRuntime().maxMemory() / 4); 29 | } 30 | 31 | public void setLimit(long new_limit) { 32 | limit = new_limit; 33 | Log.i(TAG, "MemoryCache will use up to " + limit / 1024. / 1024. + "MB"); 34 | } 35 | 36 | public Bitmap get(String id) { 37 | try { 38 | if (!cache.containsKey(id)) 39 | return null; 40 | return cache.get(id); 41 | } catch (NullPointerException ex) { 42 | ex.printStackTrace(); 43 | return null; 44 | } 45 | } 46 | 47 | public void put(String id, Bitmap bitmap) { 48 | try { 49 | if (cache.containsKey(id)) 50 | size -= getSizeInBytes(cache.get(id)); 51 | cache.put(id, bitmap); 52 | size += getSizeInBytes(bitmap); 53 | checkSize(); 54 | } catch (Throwable th) { 55 | th.printStackTrace(); 56 | } 57 | } 58 | 59 | private void checkSize() { 60 | Log.i(TAG, "cache size=" + size + " length=" + cache.size()); 61 | if (size > limit) { 62 | // Least recently accessed item will be the first one iterated 63 | Iterator> iter = cache.entrySet().iterator(); 64 | while (iter.hasNext()) { 65 | Entry entry = iter.next(); 66 | size -= getSizeInBytes(entry.getValue()); 67 | iter.remove(); 68 | if (size <= limit) 69 | break; 70 | } 71 | Log.i(TAG, "Clean cache. New size " + cache.size()); 72 | } 73 | } 74 | 75 | public void clear() { 76 | try { 77 | cache.clear(); 78 | size = 0; 79 | } catch (NullPointerException ex) { 80 | ex.printStackTrace(); 81 | } 82 | } 83 | 84 | long getSizeInBytes(Bitmap bitmap) { 85 | if (bitmap == null) 86 | return 0; 87 | return bitmap.getRowBytes() * bitmap.getHeight(); 88 | } 89 | } -------------------------------------------------------------------------------- /app/src/main/java/id/co/imastudio/santri/jogjatourismplace/adapter/Utils.java: -------------------------------------------------------------------------------- 1 | package id.co.imastudio.santri.jogjatourismplace.adapter; 2 | import java.io.InputStream; 3 | import java.io.OutputStream; 4 | 5 | public class Utils { 6 | public static void CopyStream(InputStream is, OutputStream os) 7 | { 8 | final int buffer_size=1024; 9 | try 10 | { 11 | byte[] bytes=new byte[buffer_size]; 12 | for(;;) 13 | { 14 | int count=is.read(bytes, 0, buffer_size); 15 | if(count==-1) 16 | break; 17 | os.write(bytes, 0, count); 18 | } 19 | } 20 | catch(Exception ex){} 21 | } 22 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_camera.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_gallery.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_manage.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_send.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_share.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_slideshow.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/jogjaicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basriumar12/hacktoberFest/7648bdfb651429dad667b86c005314305f7fdb4b/app/src/main/res/drawable/jogjaicon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/side_nav_bar.xml: -------------------------------------------------------------------------------- 1 | 3 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/temp_img.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basriumar12/hacktoberFest/7648bdfb651429dad667b86c005314305f7fdb4b/app/src/main/res/drawable/temp_img.png -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_error.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_list_wisata.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_login.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 16 | 17 |