Wallpaper Api

October 30, 2015 0 Comments

Free Wallpaper Api for upload your wallpaper and convert into Rest Api.

 

  1. create a/c on desktoppr.co

  2. Upload Some Images on your aacount.

  3. After Creating your account you get Key Also. like : J-fSzynxMPeeWvrETJSn

  4. Now we use different url.

  5. Like you want to get only your wallpaper than use :

  6. https://api.desktoppr.co/1/users/siddharth/wallpapers => here "siddharth" is your username.


For More Detail aboout Wallpaper Api. read Document of desktoppr document

Download Complete Code : DOWNLOAD

1)=> https://api.desktoppr.co/1/users/christmaswallpaper/wallpapers?safe_filter=all

2)=>https://api.desktoppr.co/1/users/christmaswallpaper/wallpapers

3)=>Followers : https://api.desktoppr.co/1/users/christmaswallpaper

4)=>Randomwallpaper of yours: https://api.desktoppr.co/1/users/christmaswallpaper/wallpapers/random

5)=> Likes : https://api.desktoppr.co/1/users/christmaswallpaper/likes

 

========================= We Check the Json  :
{
"response": {
"id": 247,
"bytes": 532148,
"created_at": "2012-04-11T10:28:38.562Z",
"image": {
"url": "http://a.desktopprassets.com/wallpapers/ce7702e6f7dba40cabcb063307b4e64e1683a281/_1680x1050_wallpaper-2.jpeg",
"thumb": {
"url": "http://a.desktopprassets.com/wallpapers/ce7702e6f7dba40cabcb063307b4e64e1683a281/thumb__1680x1050_wallpaper-2.jpeg",
"width": 296,
"height": 185
},
"preview": {
"url": "http://a.desktopprassets.com/wallpapers/ce7702e6f7dba40cabcb063307b4e64e1683a281/preview__1680x1050_wallpaper-2.jpeg",
"width": 960,
"height": 600
}
},
"height": 1050,
"width": 1680,
"review_state": "safe",
"uploader": "keithpitt",
"user_count": 523,
"likes_count": 72,
"palette": [
"20201E",
"676663",
"686764",
"8B8B8C",
"8C8C94",
"8C948C",
"DADAD9",
"DBDADA",
"DBDBDA",
"E3E3E2"
],
"url": "https://www.desktoppr.co/wallpapers/247"
}
}

====== Setup The New Project on IDE

======= Now We Convert the Complete Json to Pojo Class for Parsing the Rest API.

Simple Used the : JSON TO POJO (http://www.jsonschema2pojo.org/) .

====== Add All The Model class in Your package.

Add the Gradle file for GSON :
compile 'com.google.code.gson:gson:2.3.1'


====== now we start the parsing of all the data

First We Add Gradle Dependancy :
compile 'com.squareup.retrofit:retrofit:1.9.0'

This is a Interface For RectroFit Method

public interface iDesktoper {


@GET("/wallpapers")
void getAllWallpaper(Callback<DesktoperModelResponce> callback);

}

In Main Activity Set Adapter :
iDesktoper git;

RestAdapter restAdapter = new RestAdapter.Builder().setLogLevel(RestAdapter.LogLevel.FULL).setEndpoint(Constant.BASE_URL).build();
git = restAdapter.create(iDesktoper.class);

git.getAllWallpaper(new Callback<DesktoperModelResponce>() {
@Override
public void success(DesktoperModelResponce response1, Response response) {

Log.i(MainActivity.class.getName(), Utils.convertResponseToString(response));

adapter = new CardListAdapater(MainActivity.this, response1.getResponse());

rv_list_card.setAdapter(adapter);
rv_list_card.setLayoutManager(new LinearLayoutManager(MainActivity.this));


// for (com.pemikir.desktopper.Model.Response rs : response1.getResponse()) {
// Log.i(MainActivity.class.getName(), rs.getUrl());
// Log.i(MainActivity.class.getName(), rs.getImage().getThumb().toString());
// }


}

@Override
public void failure(RetrofitError error) {
Log.i(MainActivity.class.getName(), error.getResponse().toString());
Log.i(MainActivity.class.getName() + "Error", Utils.convertResponseToString(error.getResponse()));
}
});

 

For Image Rendering We can Use Many Item UIL (universal image Loader) , Picasso , Glider .

Now Download the code You get both of code. like picasso, Glider .
public class CardListAdapater extends RecyclerView.Adapter<CardListAdapater.CardListViewHolder> {

List<Response> cardList;
Context context;

public CardListAdapater(Context context, List<Response> cardlist) {
this.cardList = cardlist;
this.context = context;
}

@Override
public CardListViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_card, null);

CardListViewHolder viewHolder = new CardListViewHolder(view);
return viewHolder;
}

@Override
public void onBindViewHolder(final CardListViewHolder holder, int position) {

Log.i("Palete", "" + cardList.get(position).getPalette().get(1).toString() + "=====" + cardList.get(position).getPalette().get(0));
try {
holder.bottom_plate.setBackgroundColor(Color.parseColor("#" + cardList.get(position).getPalette().get(1).toString()));
holder.bottom_plate.bringToFront();
} catch (Exception e) {
e.printStackTrace();
}

// Picasso.with(context).load(cardList.get(position).getImage().getPreview().getUrl()).into(holder.card_image, null);

Glide.with(context).load(cardList.get(position).getImage().getPreview().getUrl()).into(holder.card_image);

}


@Override
public int getItemCount() {
return cardList.size();
}

public class CardListViewHolder extends RecyclerView.ViewHolder {
ImageView card_image;
View bottom_plate;
TextView tv_card_name, tv_card_description, tv_card_link;

public CardListViewHolder(View itemView) {
super(itemView);
this.card_image = (ImageView) itemView.findViewById(R.id.card_image);
// this.bottom_plate = (RelativeLayout) itemView.findViewById(R.id.bottom_plate);
this.bottom_plate = itemView.findViewById(R.id.bottom_plate);

this.tv_card_name = (TextView) itemView.findViewById(R.id.tv_card_name);
this.tv_card_description = (TextView) itemView.findViewById(R.id.tv_card_description);
this.tv_card_link = (TextView) itemView.findViewById(R.id.tv_card_link);

}
}
}

 

====================== Main Activity Code ===

 
public class MainActivity extends AppCompatActivity {

DesktoperAPP mApplication;
RecyclerView rv_list_card;
CardListAdapater adapter;
// DesktoperModelResponce Responsemodel;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

mApplication = (DesktoperAPP) getApplicationContext();

init();


}

private void init() {

rv_list_card = (RecyclerView) findViewById(R.id.recycler_view);

mApplication.getGit().getAllWallpaper(new Callback<DesktoperModelResponce>() {
@Override
public void success(DesktoperModelResponce response1, Response response) {

Log.i(MainActivity.class.getName(), Utils.convertResponseToString(response));

adapter = new CardListAdapater(MainActivity.this, response1.getResponse());

rv_list_card.setAdapter(adapter);
rv_list_card.setLayoutManager(new LinearLayoutManager(MainActivity.this));


// for (com.pemikir.desktopper.Model.Response rs : response1.getResponse()) {
// Log.i(MainActivity.class.getName(), rs.getUrl());
// Log.i(MainActivity.class.getName(), rs.getImage().getThumb().toString());
// }


}

@Override
public void failure(RetrofitError error) {
Log.i(MainActivity.class.getName(), error.getResponse().toString());
Log.i(MainActivity.class.getName() + "Error", Utils.convertResponseToString(error.getResponse()));

}
});

}

 

 

 

 

 

 

Contributer

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard. Google

0 comments:

Hot-product

Best Watch Store

Popular Posts

Contact Form

Name

Email *

Message *