High Contrast Browsing - Nook Touch Themes and Apps

Ran across this for Opera -
1. Install one of the Opera browsers (mobile seems to accept it)
2. Create a css file containing something like the following (tweak to your liking), put it somewhere accessible on your phone.
Code:
Code:
* { background: black ! important; color: white !important }
:link, :link * { color: #00ffff !important }
:visited, :visited * { color: #ff00ff !important }
3. Open Opera and type "opera:config" into the url field.
4. Click "Quick find" and type "css" to filter the options.
5. Tick the "User CSS" tick box
6. In the "Local CSS File" choose the css file you made earlier. (to go up directories use the back arrow on the status bar)
7. Save your changes to the config screen.
8. Restart Opera
Seems to help some.
Now if they would only enable the volume buttons for scroll we'd be set.
If someone really wants to experiment here is a link to a fuller CSS file but beware it is dark and needs to essentially be reversed to be nice on the Nook
usercss.ru/styles/night/night.css
Click to expand...
Click to collapse

Here's it reversed
Code:
* { background: #ffffff ! important; color: #000000 !important }
:link, :link * { color: #686868 !important }
:visited, :visited * { color: #888888 !important }

THanks for this.
It works.
With my opera (v. 11.50) i had to:
1. goto opera:config
2. search for css
3. Tick in the Author display mode: author CSS and user CSS on.
4. Tick in the User display mode: author CSS and user CSS on.
5. under User prefs, scroll down to Local CSS file
6. Locate your uploaded css file.
7. Click Save in every section, like Author display mode, User display mode, and User prefs.
Looks much better for news sites on the e-ink screen.

I took carpeVideo's link and messed with the css. It looks nice and high-contrasty mostly in Opera. All I did was change color values and take out a bit of code I didn't think needed to be there. YMMV, I'm not responsible, remove it if you don't like it, etc.
@namespace url(http://www.w3.org/1999/xhtml);
html {
background:#fff !important;
}
html * {
background: none !important;
color:#000 !important;
border-color:#000 !important;
border-width:0 !important;
}
html a,
html a * {
color:#000 !important;
text-decoration:underline !important
}
html a:visited,
html a:visited *,
html a:active,
html a:active * {
color:#737373 !important
}
html input,
html select,
html button,
html textarea {
background:#fff !important;
border: 1px solid #000 !important;
border-top-color: #000 !important;
border-bottom-color: #000 !important;
}
html input[type=button],
html input[type=submit],
html input[type=reset],
html input[type=image],
html button {
border-top-color: #000 !important;
border-bottom-color: #000 !important;
}
html input:focus,
html select:focus,
html option:focus,
html button:focus,
html textarea:focus {
background:#fff !important;
color:#000 !important;
border-color: #000 #000 #000 !important;
/*border-top-color: #000 !important;*/
outline: 2px solid #000 !important;
}
html input[type=button]:focus,
html input[type=submit]:focus,
html input[type=reset]:focus,
html input[type=image]:focus,
html button:focus {
border-color: #000 #000 #000 !important;
}
html input[type=radio] {
background:none !important;
border-color:#333 !important;
border-width:0 !important;
}
html img[src],
html input[type=image] {opacity:.5}
html img[src]:hover,
html input[type=image]:hover {opacity:1}
html,
html body {
scrollbar-base-color: #000 !important;
scrollbar-face-color: #fff !important;
scrollbar-shadow-color: #fff !important;
scrollbar-highlight-color: #fff !important;
scrollbar-dlight-color: #fff !important;
scrollbar-darkshadow-color: #000 !important;
scrollbar-track-color: #000 !important;
scrollbar-arrow-color: #000 !important;
scrollbar-3dlight-color: #fff !important;
}
/* Link shadows */
/*
@media screen and (min-width: 128px) {
html a:hover,
html a:hover * {
background-color: #fff !important;
text-shadow: 0 0 1em #000 !important;
}
}
*/
/* Webkit */
@media all and (-webkit-min-device-pixel-ratio:0) {
html body * {
-webkit-transition: color 1s ease-in, background-color 2s ease-out !important;
}
html a,
html textarea,
html input,
html select {
-webkit-transition: color .4s ease-in, background-color .4s ease-out !important;
}
html img[src],
html input[type=image] {
-webkit-transition: opacity .4s ease-in !important;
}
html input:focus,
html select:focus,
html option:focus,
html button:focus,
html textarea:focus {
outline-style: outset !important;
}
}

Looks nice cymoze - the only issue I see is photos seem washed out. I will try some experimentation and see if I can come up with something.

A simple change fixes the photo issue:
html img[src],
html input[type=image] {opacity:1}
html img[src]:hover,
html input[type=image]:hover {opacity:1}
for those who don't want to hunt for the above section (credit to Cymoze - I only changed 1 number)
Code:
@namespace url(http://www.w3.org/1999/xhtml);
@namespace url(http://www.w3.org/1999/xhtml);
html {
background:#fff !important;
}
html * {
background: none !important;
color:#000 !important;
border-color:#000 !important;
border-width:0 !important;
}
html a,
html a * {
color:#000 !important;
text-decoration:underline !important
}
html a:visited,
html a:visited *,
html a:active,
html a:active * {
color:#737373 !important
}
html input,
html select,
html button,
html textarea {
background:#fff !important;
border: 1px solid #000 !important;
border-top-color: #000 !important;
border-bottom-color: #000 !important;
}
html input[type=button],
html input[type=submit],
html input[type=reset],
html input[type=image],
html button {
border-top-color: #000 !important;
border-bottom-color: #000 !important;
}
html input:focus,
html select:focus,
html option:focus,
html button:focus,
html textarea:focus {
background:#fff !important;
color:#000 !important;
border-color: #000 #000 #000 !important;
/*border-top-color: #000 !important;*/
outline: 2px solid #000 !important;
}
html input[type=button]:focus,
html input[type=submit]:focus,
html input[type=reset]:focus,
html input[type=image]:focus,
html button:focus {
border-color: #000 #000 #000 !important;
}
html input[type=radio] {
background:none !important;
border-color:#333 !important;
border-width:0 !important;
}
html img[src],
html input[type=image] {opacity:1}
html img[src]:hover,
html input[type=image]:hover {opacity:1}
html,
html body {
scrollbar-base-color: #000 !important;
scrollbar-face-color: #fff !important;
scrollbar-shadow-color: #fff !important;
scrollbar-highlight-color: #fff !important;
scrollbar-dlight-color: #fff !important;
scrollbar-darkshadow-color: #000 !important;
scrollbar-track-color: #000 !important;
scrollbar-arrow-color: #000 !important;
scrollbar-3dlight-color: #fff !important;
}
/* Link shadows */
/*
@media screen and (min-width: 128px) {
html a:hover,
html a:hover * {
background-color: #fff !important;
text-shadow: 0 0 1em #000 !important;
}
}
*/
/* Webkit */
@media all and (-webkit-min-device-pixel-ratio:0) {
html body * {
-webkit-transition: color 1s ease-in, background-color 2s ease-out !important;
}
html a,
html textarea,
html input,
html select {
-webkit-transition: color .4s ease-in, background-color .4s ease-out !important;
}
html img[src],
html input[type=image] {
-webkit-transition: opacity .4s ease-in !important;
}
html input:focus,
html select:focus,
html option:focus,
html button:focus,
html textarea:focus {
outline-style: outset !important;
}
}

Thanks! this one is even better!

it works awesome on opera mobile. thanks

Thanks! This works great.

I came up with this css. Its a little bit of the above css scripts. This loads more images, changed font face, font colors and link formatting.
HTML:
* {line-height: 1.3 !important; color: #000 !important; font-family: "Malabar", Droidserif, Caecilia, Amasis, serif !important}
body, table, div {background-color: #FFF !important}
:link, :link * { color: #808080 !important}
:visited, :visited * { color: #333 !important}
a:hover,a:active{outline:0 !important; text-decoration:none !important}
a {text-decoration: none !important; line-height: inherit !important; font-weight: inherit !important}
a:focus{outline:thin dotted !important}
a {border-bottom: 1px dotted #333 !important}
a[href$=jpg], a[href$=jpeg], a[href$=jpe], a[href$=png], a[href$=gif] {
text-decoration: none !important;
border: 0 none !important;
}
a img {
text-decoration: none !important;
border: 0 none !important;
}
p {font-size: 1.5em !important;line-height: 1.3 !important;}

This is awesome! Will be getting this as soon as I can.
After I brush up on my CSS, I could experiment with some other styles. First, we need an HTML page that shows all of the different styles. I could host that page if someone made it...

Plan to install this on my mom's simple touch this weekend...is there a "latest" version since the one in march?

Related

Drawer navigation with navigation toggle

Hi. Can you link to some simple tutorial or other help for Drawer navigation with navigation toggle. I plan to use lot of fragments.
I have implemented Navigation drawer. But when I open fragment and add back arrow when fragment is open instead "navigation hamburger icon", it doesn't go back to starting page but instead open drawer again. Here is the code I mostly got from tutorial,but want to move on:
MainActivity:
Code:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
listView=(ListView)findViewById(R.id.listView);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
toolbar=(Toolbar) findViewById(R.id.app_bar);
setSupportActionBar(toolbar);
//getSupportActionBar().setDisplayShowHomeEnabled(true);
final NavigationDrawerFragment drawerFragment=(NavigationDrawerFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_navigation_drawer);
drawerFragment.setUp(R.id.fragment_navigation_drawer,(DrawerLayout)findViewById(R.id.drawer_layout),toolbar);
adapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,sports);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
selectItem(position);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mDrawerLayout.closeDrawers();
}
});
}
protected void setFragment(Fragment fragment) {
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction =
fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.drawer_layout, fragment);
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
}
private void selectItem(int position)
{
switch (position) {
case 0:
setFragment(new SoccerFragment());
break;
}
}
and for navigation fragment:
Code:
public NavigationDrawerFragment() {
// Required empty public constructor
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mUserLearnedDrawer=Boolean.valueOf(readFromPreferences(getActivity(), KEY_USER_LEARNED_DRAWER, "false"));
if (savedInstanceState!=null)
{
mFromSavedInstanceState=true;
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_navigation_drawer, container, false);
}
public void setUp(int fragmentId,DrawerLayout drawerLayout,Toolbar toolbar) {
//containerView=getActivity().findViewById(fragmentId);
mDrawerLayout=drawerLayout;
mDrawerToggle=new ActionBarDrawerToggle(getActivity(),drawerLayout,toolbar,R.string.drawer_open,R.string.drawer_close)
{
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
if (!mUserLearnedDrawer)
{
mUserLearnedDrawer=true;
saveToPreferences(getActivity(), KEY_USER_LEARNED_DRAWER,mUserLearnedDrawer+"");
}
getActivity().invalidateOptionsMenu();
}
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
getActivity().invalidateOptionsMenu();
}
};
//if (mUserLearnedDrawer && mFromSavedInstanceState)
//{
// mDrawerLayout.openDrawer(containerView);
//}
mDrawerLayout.setDrawerListener(mDrawerToggle);
mDrawerLayout.post(new Runnable() {
@Override
public void run() {
mDrawerToggle.syncState();
}
});
}
public static void saveToPreferences(Context context,String preferenceName,String preferenceValue)
{
SharedPreferences sharedPreferences=context.getSharedPreferences(PREF_FILE_NAME,Context.MODE_PRIVATE);
SharedPreferences.Editor editor=sharedPreferences.edit();
editor.putString(preferenceName, preferenceValue);
editor.apply(); //or commit()
}
public static String readFromPreferences(Context context,String preferenceName,String defaultValue)
{
SharedPreferences sharedPreferences=context.getSharedPreferences(PREF_FILE_NAME, Context.MODE_PRIVATE);
return sharedPreferences.getString(preferenceName,defaultValue);
}
}

Opera GestureBox extension

For those who missing page UP and page DOWN or mouse gestures, miss no more.
Install Opera Mobile Labs build with extensions and GestureBox extension. As you can see from screenshoots it's powerful tool
Bonus
For white background and black text (disables background image as well) save this as user.css to /data/data/com.opera.browser.extensions/opera/styles/ (usable with Opera classic too):
Code:
* { background: white ! important; color: black !important }
:link, :link * { color: #222222 !important }
:visited, :visited * { color: #333333 !important }

[TUTORIAL][ANDROID] How to add touch events to RecyclerView

At first, it probably seems a better choice to use RecyclerViews instead of the ordinary ListViews but one of the issues that people come across is that there are no touch events implemented in RecyclerViews.
While developing Chatto (re-writing from scratch), I came up with a very logical solution for this. If you are you currently using RecyclerViews, you should be familiar with ViewHolders.
Firstly, in your model layout file for the RecyclerView (.xml file), add an id for the layout that you are using. In my layout file, I'm using a RelativeLayout.
Code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="50dp"
android:paddingBottom="5dp"
android:id="@+id/chatroomListRelativeRow">
Now let's take a look at a snippet from a custom ViewHolder class that I wrote for Chatto.
Code:
public class RoomViewHolder extends RecyclerView.ViewHolder{
private TextView mLblRoomName;
private TextView mLblRoomCounter;
private ImageView mImgRoomType;
private RelativeLayout chatroomListRelativeRow;
public String roomName;
Notice the line private RelativeLayout chatroomListRelativeRow. As you can see, I've created a RelativeLayout object.
Inside the constructor of the ViewHolder class, I've linked the object back to the RelativeLayout in the .xml file.
Code:
chatroomListRelativeRow = RelativeLayout)v.findViewById(R.id.chatroomListRelativeRow);
Now we can use this object to add the onClickListeners and other touch events.
Code:
chatroomListRelativeRow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Log.d("RVH",mLblRoomName.getText().toString());
//FragMessagesList fragMessagesList = new FragMessagesList();
roomName = mLblRoomName.getText().toString();
//go to messages
}
});
In the above code, I've attached a OnClickListener to the RelativeLayout. This means when the user clicks on any part of the layout (RecyclerView row), it will perform the specified action.
Now you can try this out for yourself.
As an addition, I've also attached a OnTouchListener to the layout. In this listener, I'm simply changing the colors when user touches the row and when the row is not touched. Now let's see how its done.
In order to obtain the original color of the layout, I've created a Drawable and called the
Code:
.getBackground()
method on the layout.
Code:
final Drawable origColor = chatroomListRelativeRow.getBackground();
Now we can use this to set the color back to the original color/background when the user is not touching on the row.
Code:
chatroomListRelativeRow.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction()==MotionEvent.ACTION_DOWN){
chatroomListRelativeRow.setBackgroundColor(Color.parseColor("#212121"));
}
else{
chatroomListRelativeRow.setBackground(origColor);
}
return false;
}
});
That's all there is to it!

Google Maps API v2 tutorials wanted.

Hi everyone,
I'm working on my first app (still a noob) with Google Maps API v2 in Android Studio and followed a couple of tutorials to get the user's current position and draw a path between two points (not working right now). I am using Retrofit to parse JSON. Now I have a current position and when the user taps the screen, a green marker appears and when the user taps again a red marker appears. Clicking on my driving button to get the route between red and green does nothing.
I would like the current position of the user also to be the starting point (so no extra markers). A user has to be able to enter an address and a new marker has to be set at that address. A route should be drawn between the current position of the user and the new address (showing distance and time) Like Runkeeper, I would like that - when the user moves - the marker at the current position moves with him.
I just can't find any good up to date tutorials which I can use to create this? Is someone able to help me or could someone look at my code? Or know any good tutorials?
Code:
package com.lemonkicks.trackmycab.trackmycab;
import android.Manifest;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.location.Location;
import android.os.Build;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.lemonkicks.trackmycab.trackmycab.POJO.Example;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GoogleApiAvailability;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.Polyline;
import com.google.android.gms.maps.model.PolylineOptions;
import java.util.ArrayList;
import java.util.List;
import retrofit.Call;
import retrofit.Callback;
import retrofit.GsonConverterFactory;
import retrofit.Response;
import retrofit.Retrofit;
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback,
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener,
LocationListener {
private GoogleMap mMap;
GoogleApiClient mGoogleApiClient;
Location mLastLocation;
Marker mCurrLocationMarker;
LocationRequest mLocationRequest;
LatLng origin;
LatLng dest;
ArrayList<LatLng> MarkerPoints;
TextView ShowDistanceDuration;
Polyline line;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
ShowDistanceDuration = (TextView) findViewById(R.id.show_distance_time);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
checkLocationPermission();
}
// Initializing
MarkerPoints = new ArrayList<>();
//show error dialog if Google Play Services not available
if (!isGooglePlayServicesAvailable()) {
Log.d("onCreate", "Google Play Services not available. Ending Test case.");
finish();
} else {
Log.d("onCreate", "Google Play Services available. Continuing.");
}
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Setting onclick event listener for the map
mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
@Override
public void onMapClick(LatLng point) {
// clearing map and generating new marker points if user clicks on map more than two times
if (MarkerPoints.size() > 1) {
mMap.clear();
MarkerPoints.clear();
MarkerPoints = new ArrayList<>();
ShowDistanceDuration.setText("");
}
// Adding new item to the ArrayList
MarkerPoints.add(point);
Log.i("onMapClick", "Map clicked, number of points is now " + MarkerPoints.size());
// Creating MarkerOptions
MarkerOptions options = new MarkerOptions();
// Setting the position of the marker
options.position(point);
/**
* For the start location, the color of marker is GREEN and
* for the end location, the color of marker is RED.
*/
if (MarkerPoints.size() == 1) {
options.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));
} else if (MarkerPoints.size() == 2) {
options.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED));
}
// Add new marker to the Google Map Android API V2
mMap.addMarker(options);
// Checks, whether start and end locations are captured
if (MarkerPoints.size() >= 2) {
origin = MarkerPoints.get(0);
dest = MarkerPoints.get(1);
Log.i("onMapClick", "origin and dest now set.");
} else {
Log.i("onMapClick", "origin and dest not set as number of marker points is " + MarkerPoints.size());
}
}
});
Button btnDriving = (Button) findViewById(R.id.btnDriving);
btnDriving.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
build_retrofit_and_get_response("driving");
}
});
Button btnWalk = (Button) findViewById(R.id.btnWalk);
btnWalk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
build_retrofit_and_get_response("walking");
}
});
//Initialize Google Play Services
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION)
== PackageManager.PERMISSION_GRANTED) {
buildGoogleApiClient();
mMap.setMyLocationEnabled(true);
}
} else {
buildGoogleApiClient();
mMap.setMyLocationEnabled(true);
}
}
protected synchronized void buildGoogleApiClient() {
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
mGoogleApiClient.connect();
}
@Override
public void onConnected(Bundle bundle) {
mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(1000);
mLocationRequest.setFastestInterval(1000);
mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION)
== PackageManager.PERMISSION_GRANTED) {
LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
}
}
@Override
public void onConnectionSuspended(int i) {
}
@Override
public void onLocationChanged(Location location) {
mLastLocation = location;
if (mCurrLocationMarker != null) {
mCurrLocationMarker.remove();
}
//Place current location marker
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(latLng);
markerOptions.title("Current Position");
markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_MAGENTA));
mCurrLocationMarker = mMap.addMarker(markerOptions);
//move map camera
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
mMap.animateCamera(CameraUpdateFactory.zoomTo(11));
//stop location updates
if (mGoogleApiClient != null) {
LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
}
}
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
}
private void build_retrofit_and_get_response(String type) {
String url = "https://maps.googleapis.com/maps/";
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(url)
.addConverterFactory(GsonConverterFactory.create())
.build();
RetrofitMaps service = retrofit.create(RetrofitMaps.class);
Call<Example> call = service.getDistanceDuration("metric", origin.latitude + "," + origin.longitude,dest.latitude + "," + dest.longitude, type);
call.enqueue(new Callback<Example>() {
@Override
public void onResponse(Response<Example> response, Retrofit retrofit) {
try {
//Remove previous line from map
if (line != null) {
line.remove();
}
// This loop will go through all the results and add marker on each location.
for (int i = 0; i < response.body().getRoutes().size(); i++) {
String distance = response.body().getRoutes().get(i).getLegs().get(i).getDistance().getText();
String time = response.body().getRoutes().get(i).getLegs().get(i).getDuration().getText();
ShowDistanceDuration.setText("Distance:" + distance + ", Duration:" + time);
String encodedString = response.body().getRoutes().get(0).getOverviewPolyline().getPoints();
List<LatLng> list = decodePoly(encodedString);
line = mMap.addPolyline(new PolylineOptions()
.addAll(list)
.width(20)
.color(Color.RED)
.geodesic(true)
);
}
} catch (Exception e) {
Log.d("onResponse", "There is an error");
e.printStackTrace();
}
}
@Override
public void onFailure(Throwable t) {
Log.d("onFailure", t.toString());
}
});
}
private List<LatLng> decodePoly(String encoded) {
List<LatLng> poly = new ArrayList<LatLng>();
int index = 0, len = encoded.length();
int lat = 0, lng = 0;
while (index < len) {
int b, shift = 0, result = 0;
do {
b = encoded.charAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
lat += dlat;
shift = 0;
result = 0;
do {
b = encoded.charAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
lng += dlng;
LatLng p = new LatLng( (((double) lat / 1E5)),
(((double) lng / 1E5) ));
poly.add(p);
}
return poly;
}
// Checking if Google Play Services Available or not
private boolean isGooglePlayServicesAvailable() {
GoogleApiAvailability googleAPI = GoogleApiAvailability.getInstance();
int result = googleAPI.isGooglePlayServicesAvailable(this);
if(result != ConnectionResult.SUCCESS) {
if(googleAPI.isUserResolvableError(result)) {
googleAPI.getErrorDialog(this, result,
0).show();
}
return false;
}
return true;
}
public static final int MY_PERMISSIONS_REQUEST_LOCATION = 99;
public boolean checkLocationPermission(){
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED) {
// Asking user if explanation is needed
if (ActivityCompat.shouldShowRequestPermissionRationale(this,
Manifest.permission.ACCESS_FINE_LOCATION)) {
// Show an explanation to the user *asynchronously* -- don't block
// this thread waiting for the user's response! After the user
// sees the explanation, try again to request the permission.
//Prompt the user once explanation has been shown
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
MY_PERMISSIONS_REQUEST_LOCATION);
} else {
// No explanation needed, we can request the permission.
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
MY_PERMISSIONS_REQUEST_LOCATION);
}
return false;
} else {
return true;
}
}
}

if anyone could help would be great (if or else statement)

i have been designing my own android app and have fell into a problem
im trying to call all avi, mp4, m3u8 and mkv files from my server this is my code i have but im unable to set it up to call all 4 i can only call the the other 2 file formats
PHP:
protected void onStart() {
super.onStart();
boolean isMxPlayerInstalled=isAppInstalled(PlayerActivty.this,MX_PLAYER_PACKAGE_NAME);
try {
if(isMxPlayerInstalled) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setPackage("nppl3.hd.video.player");
String username = getIntent().getStringExtra("USERNAME");
String password = getIntent().getStringExtra("PASSWORD");
String mode = getIntent().getStringExtra("stream_type");
String stream_id = getIntent().getStringExtra("stream_id");
String action = getIntent().getStringExtra("action");
if (action.equalsIgnoreCase("get_vod_streams")) {
extension = ".mp4";
} else {
extension = ".avi";
}

Categories

Resources