Skip to content

Instantly share code, notes, and snippets.

@eserdinyo
Created January 7, 2019 17:46
Show Gist options
  • Save eserdinyo/ff96d2d228453a6e59c53a5b7ea1fa03 to your computer and use it in GitHub Desktop.
Save eserdinyo/ff96d2d228453a6e59c53a5b7ea1fa03 to your computer and use it in GitHub Desktop.
Mobile Programmig Final Exam
#### FRAGMENTS ####
1-)
View view=inflater.inflate(R.layout.fragment_version , container, false);
Apilevel = view.findViewById(R.id.tv_Apilevel);
2-)
ArrayAdapter<String> arrayAdapter=new ArrayAdapter<String>(getActivity(),android.R.layout.simple_list_item_1,listAndroidVersion);
lvVersions.setAdapter(arrayAdapter);
3-)
lvVersions.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String api = listAndroidApi [position];
apiListener.onSetApi(api);
}
});
4-)
ApiFragment fragment = new ApiFragment();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
fragment.setArguments(args);
5-)
if (getArguments() != null) {
paramApi = getArguments().getString(ARG_PARAM1);
}
### JSON ###
1-)
JsonArrayRequest request = new JsonArrayRequest(Request.Method.GET, url, null, new Response.Listener<JSONArray>()
2-)
JSONObject object = response.getJSONObject(count);
JSONArray jsonArray = object.getJSONArray("illeri");
3-)
JSONObject obj = jsonArray.getJSONObject(i);
cities.add(obj.getString("il"));
imageURLS.add(obj.getString("resim"));
4-)
Intent intent= new Intent(MainActivity.this,SecondActivity.class);
intent.putExtra("EXTRA_CITY",cities.get(position));
intent.putExtra("EXTRA_IMAGE",imageURLS.get(position));
5-)
Intent intent=getIntent();
String Cname = intent.getStringExtra("EXTRA_CITY");
String IMname = intent.getStringExtra("EXTRA_IMAGE");
6-)
imview = findViewById(R.id.imageView);
Picasso.get().load(IMname).into(imview);
### GOOGLE MAP ###
1-)
zoomControls.setOnZoomInClickListener(new View.OnClickListener() {
public void onClick(View v) {
mMap.moveCamera(CameraUpdateFactory.zoomIn());
}
});
2-)
btnMapType.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if(mMap.getMapType() == GoogleMap.MAP_TYPE_NORMAL){
mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
btnMapType.setText("Norm");
}else if(mMap.getMapType() == GoogleMap.MAP_TYPE_SATELLITE){
mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
btnMapType.setText("Sat");
}
}
});
3-)
String location = etLocation.getText().toString();
if(!TextUtils.isEmpty(location)){
Geocoder geocoder = new Geocoder(MapsActivity.this);
try {
List<Address> addressList = geocoder.getFromLocationName(location,1);
Address address = addressList.get(0);
LatLng myLatLng = new LatLng(address.getLatitude(),address.getLongitude());
mMap.addMarker(new MarkerOptions().position(myLatLng).title("Here is "+location));
mMap.moveCamera(CameraUpdateFactory.newLatLng(myLatLng));
} catch (IOException e) {
e.printStackTrace();
}
}
### JSOUP ###
1-)
public class GetData extends AsyncTask<String,Void,Document>
new GetData().execute(URL);
2-)
protected void onPostExecute(Document document) {
super.onPostExecute(document);
progressDialog.dismiss();
Elements elements = document.select("td.haberResim img");
for(int i=0;i<elements.size();i++){
veriList.add(elements.get(i).attr("src"));
}
Elements elements = document.select("td.haberDetay");
for(Element e:elements){
veriList.add(e.text());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment