EarthView Android Library


Source link: https://github.com/PDDStudio/earthview-android

EarthView Android Library

A simple and easy to use API to integrate EarthView with Google into your android application.

Showcase

Advanced Demo Application (Beta)

To showcase the different possibilities of this library I've created a demo 'Wallpaper Application'. You can find the source for this application in the ps-app/ folder. In case you want to install the Application, feel free to do so! It's on Google Play™

!! Translators needed !!

You can help translating EarthViewer into your native language via OneSkyApp: Contribute to EarthViewer

Advanced Demo Screenshot

Simple Demo Application

You can find a simple demo application in the app/ folder which you can also download here.

Getting Started

Include the library into your project by adding the following line to your build.gradle: compile 'com.pddstudio:earthview-android:[VERSION]' Note: To make sure you're using the latest version, take a look at the maven badge above

Usage

  • Implement either SingleEarthViewCallback (for a single EarthView) or EarthViewCallback (for multiple EarthViews) into your Activity, Adapter or any other class where you want to load the EarthView's.
  • Get an instance of the EarthView by calling:
EarthView.withGoogle()
  • Fire the event which fit's your needs, you'll get the results through the callback interface you provide in your project.

Fetching a single EarthView

A quick sample to fetch a single EarthView

public class MainActivity extends AppCompatActivity implements SingleEarthViewCallback {

Button loadBtn;

@Override
  protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);

setSupportActionBar(toolbar);

 loadBtn = (Button) findViewById(R.id.load_wall_btn);

loadBtn.setOnClickListener(new View.OnClickListener() {

 @Override

 public void onClick(View v) {

 //in case you want to get a random wallpaper

 EarthView.withGoogle().getRandomEarthWallpaper(MainActivity.this);

 //in case you want to get a specific EarthWallpaper

 EarthView.withGoogle().getEarthWallpaper(earthWallpaperIdentifier, this);

 
}

}
);

  
}

  @Override
  public void onStartedLoading() {

//in case you want to show a loading dialog or anything else
  
}

@Override
  public void onFinishedLoading(EarthWallpaper earthWallpaper) {

//check whether the result is null or not

if(earthWallpaper != null) {

 //do whatever you want to do with the EarthWallpaper object

}

  
}

}

Fetching multiple EarthViews

A quick sample to load multiple EarthViews:

public class MainActivity extends AppCompatActivity implements EarthViewCallback {

Button loadBtn;

@Override
  protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);

setSupportActionBar(toolbar);

 loadBtn = (Button) findViewById(R.id.load_wall_btn);

loadBtn.setOnClickListener(new View.OnClickListener() {

 @Override

 public void onClick(View v) {

  EarthView.withGoogle().getAllEarthWallpapers(MainActivity.this);

 
}

}
);

  
}

@Override
  public void onStartedLoading() {

//in case you want to show a loading dialog or something else you can do this here
  
}

@Override
  public void onItemLoaded(EarthWallpaper earthWallpaper) {

//just to be sure the result isn't null

if(earthWallpaper != null) {

//here you can handle what you want to do with the new item - this event get's fired every time the library has loaded a new EarthView object

}

  
}

@Override
  public void onFinishedLoading(Collection<EarthWallpaper> earthWallpapers) {

//here you can stop showing the loading dialog
//in case you don't want to handle each item seperately the complete Collection of EarthWallpapers is provided here, too 
  
}
 
}

The EarthWallpaper reference sheet

Once you received an EarthWallpaper object through the callback you can get the following information out of it:

  • The EarthView's ID (identifier - similar to the original one)
  • The EarthView's Slug
  • The EarthView's Url (Link to the official Site for this EarthView)
  • The EarthView's Title (Official Title for this EarthView)
  • The EarthView's Latitude
  • The EarthView's Longitude
  • The EarthView's Photo Url (In case you want to load it into an ImageView or save it to your storage)
  • The EarthView's Thumbnail Url (Recommended when fetching a lot of EarthViews - to reduce bandwith)
  • The EarthView's Download Url (The official Url to download this EarthView)
  • The EarthView's Region (Region where this EarthView was taken)
  • The EarthView's Country (The Country this EarthView was taken)
  • The EarthView's Attribution (Copyright information)
  • The EarthView's GoogleMaps Url (To show the direct position of this EarthView)
  • The EarthView's GoogleMaps Title (Can be used for wrapping around the GoogleMaps Url e.g)

All information can be fetched via their get-Methods. You can find more information in the EarthView JavaDoc.

Dependencies (Library)

Dependencies (Simple Demo Application)

Note: Dependencies for the Advanced Demo can be found inside the application

About & Contact

Contributors

A special thanks goes to everyone who contributed to this project!

License

Copyright 2015 Patrick J  Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License. You may obtain a copy of the License at
  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 

Resources

This is an extension for Android Lint. Rock your Android.

A simple Android library to implement a number counter with increment and decrement buttons.

An Android service to retrieve GPS locations and route stats using RxJava.

A Simplenote client for Android.

Detailed CardView that displays an action title, description, and buttons to initiate that action.

Dynamic in app URL router for Android.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes