Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.ala.ccc;
- import android.app.ListActivity;
- import android.app.ProgressDialog;
- import android.content.Intent;
- import android.os.AsyncTask;
- import android.os.Bundle;
- import android.support.design.widget.FloatingActionButton;
- import android.support.design.widget.Snackbar;
- import android.view.View;
- import android.support.design.widget.NavigationView;
- import android.support.v4.view.GravityCompat;
- import android.support.v4.widget.DrawerLayout;
- import android.support.v7.app.ActionBarDrawerToggle;
- import android.support.v7.app.AppCompatActivity;
- import android.support.v7.widget.Toolbar;
- import android.view.Menu;
- import android.view.MenuItem;
- import android.widget.ListAdapter;
- import android.widget.ListView;
- import android.widget.SimpleAdapter;
- import android.widget.Toast;
- import org.json.JSONArray;
- import org.json.JSONException;
- import org.json.JSONObject;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import retrofit.Callback;
- import retrofit.RestAdapter;
- import retrofit.RetrofitError;
- import retrofit.client.Response;
- public class Actus extends ListActivity
- implements NavigationView.OnNavigationItemSelectedListener {
- public static final String KEY_BOOK_ID = "key_book_id";
- public static final String KEY_BOOK_NAME = "key_book_name";
- public static final String KEY_BOOK_PRICE = "key_book_price";
- public static final String KEY_BOOK_STOCK = "key_book_stock";
- public static final String KEY_BOOK_date = "key_book_date";
- public static final String KEY_ID = "key_book_i";
- final String EXTRA_LOGIN = "user_login";
- public String a;
- List<Actu> flowerLis;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_services);
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
- ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
- this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
- drawer.setDrawerListener(toggle);
- toggle.syncState();
- NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
- navigationView.setNavigationItemSelectedListener(this);
- final RestAdapter restadapter = new RestAdapter.Builder().setEndpoint("http://alawerda.com/cc").build();
- api flowerapi = restadapter.create(api.class);
- flowerapi.getActus(new Callback<List<Actu>>() {
- @Override
- public void success(List<Actu> bout, Response response) {
- flowerLis = bout;
- ActusAdapter adapt = new ActusAdapter(getApplicationContext(), R.layout.item_file, flowerLis);
- setListAdapter(adapt);
- }
- @Override
- public void failure(RetrofitError error) {
- Toast.makeText(getApplicationContext(), "Failed", Toast.LENGTH_SHORT).show();
- }
- });
- }
- protected void onListItemClick(ListView l, View v, int position, long id) {
- super.onListItemClick(l, v, position, id);
- Actu actu = flowerLis.get(position);
- Intent intent2 = getIntent();
- // String a= intent2.getStringExtra(EXTRA_LOGIN);
- a = intent2.getStringExtra(EXTRA_LOGIN);
- switch (a) {
- case "alawerda":
- Intent intent4 = new Intent(this, ShoActu.class);
- intent4.putExtra(KEY_BOOK_ID, actu.getId());
- intent4.putExtra(KEY_BOOK_NAME, actu.getNomactus());
- intent4.putExtra(KEY_BOOK_PRICE, actu.getInfoactu());
- intent4.putExtra(KEY_BOOK_STOCK, actu.getImage());
- startActivity(intent4);
- break;
- case "akramwerda":
- //Intent intent = new Intent(this, ShowBoutique.class);
- //startActivity(intent);
- break;
- }
- }
- @Override
- public void onBackPressed() {
- DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
- if (drawer.isDrawerOpen(GravityCompat.START)) {
- drawer.closeDrawer(GravityCompat.START);
- } else {
- super.onBackPressed();
- }
- }
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.boutiques2, menu);
- return true;
- }
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // Handle action bar item clicks here. The action bar will
- // automatically handle clicks on the Home/Up button, so long
- // as you specify a parent activity in AndroidManifest.xml.
- int id = item.getItemId();
- //noinspection SimplifiableIfStatement
- if (id == R.id.action_settings) {
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
- @SuppressWarnings("StatementWithEmptyBody")
- @Override
- public boolean onNavigationItemSelected(MenuItem item) {
- // Handle navigation view item clicks here.
- int id = item.getItemId();
- if (id == R.id.nav_camera) {
- Intent intent = new Intent(this, Boutiques2.class);
- this.startActivity(intent);
- // Handle the camera action
- } else if (id == R.id.nav_gallery) {
- Intent intent = new Intent(this, Promos.class);
- this.startActivity(intent);
- } else if (id == R.id.nav_slideshow) {
- Intent intent = new Intent(this, Services.class);
- this.startActivity(intent);
- } else if (id == R.id.nav_manag) {
- Intent intent = new Intent(this, Actus.class);
- this.startActivity(intent);
- } else if (id == R.id.nav_share) {
- Intent intent = new Intent(this, Loginadminboutique.class);
- this.startActivity(intent);
- } else if (id == R.id.nav_send) {
- Intent intent = new Intent(this, LoginActivity.class);
- this.startActivity(intent);
- } else if (id == R.id.nav_hor){
- Intent intent = new Intent(this, Horraires.class);
- this.startActivity(intent);
- }else if (id == R.id.nav_home) {
- Intent intent = new Intent(this, MainActivity.class);
- this.startActivity(intent);
- }
- DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
- drawer.closeDrawer(GravityCompat.START);
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement