Beispiel #1
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.wall_comments);

    final ListView ListView = (ListView) findViewById(R.id.listView2);

    View profileHeader = getLayoutInflater().inflate(R.layout.wall_post, null);
    ListView.addHeaderView(profileHeader); // и используем в качестве Header"а

    final String id = getIntent().getExtras().getString("id");
    final String text = getIntent().getExtras().getString("text");
    final String like = getIntent().getExtras().getString("like");
    final String comment = getIntent().getExtras().getString("comment");
    final String repost = getIntent().getExtras().getString("repost");

    TextView textView9 = (TextView) profileHeader.findViewById(R.id.textView9);
    textView9.setText(text);

    TextView textView12 = (TextView) profileHeader.findViewById(R.id.textView12);
    textView12.setText(comment);

    TextView textView11 = (TextView) profileHeader.findViewById(R.id.textView11);
    textView11.setText(repost);

    TextView textView10 = (TextView) profileHeader.findViewById(R.id.textView10);
    textView10.setText(like);

    account.restore(this);
    if (account.access_token != null) {
      api = Api.get();
    } else {
      Toast.makeText(this, R.string.fail, Toast.LENGTH_LONG).show();
    }
  }
Beispiel #2
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.friends, container, false);

    account.restore(getActivity());

    if (account.access_token != null) {
      api = Api.get();
    } else {
      Toast.makeText(getActivity(), "Access token == null", Toast.LENGTH_LONG).show();
    }
    lvNews = (ListView) rootView.findViewById(R.id.ListView);
    getNotifications(account.user_id);

    return rootView;
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.stc);

    final long iden = getIntent().getExtras().getLong("id");
    final long cid = getIntent().getExtras().getLong("cid");

    final ListView ListView = (ListView) findViewById(R.id.lv);
    account.restore(this);
    if (account.access_token != null) {
      api = Api.get();
    }
    ListView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            StickerItem item = (StickerItem) parent.getItemAtPosition(position);

            final long stid = item.id;
            new Thread(
                    new Runnable() {
                      @Override
                      public void run() {
                        try {

                          api.sendMessage(
                              iden, cid, null, null, null, null, null, stid, null, null, null,
                              null);

                          runOnUiThread(
                              new Runnable() {
                                @Override
                                public void run() {
                                  finish();
                                }
                              });

                        } catch (Exception e) {
                          e.printStackTrace();
                        }
                      }
                    })
                .start();
          }
        });

    new Thread(
            new Runnable() {
              @Override
              public void run() {
                try {
                  // checkDonate();
                  final ArrayList<StickerItem> items = new ArrayList<>();

                  int r = 1;

                  JSONParser JSONParser = new JSONParser();
                  final JSONObject object =
                      JSONParser.getJSON(
                          "https://api.vk.com/method/store.getProducts?access_token="
                              + account.access_token
                              + "&type=stickers&extended=1&filters=purchased");
                  JSONObject json = object.optJSONObject("response");
                  final JSONArray array = json.optJSONArray("items");

                  runOnUiThread(
                      new Runnable() {
                        @Override
                        public void run() {
                          for (int i = 0; i < array.length(); i++) {
                            JSONObject user = array.optJSONObject(i);
                            String title = user.optString("title");
                            Long purchase_date = user.optLong("purchase_date");

                            final JSONArray array = user.optJSONArray("stickers");

                            for (int ii = 0; i < array.length(); ii++) {
                              JSONObject sticker = array.optJSONObject(ii);
                              final String base_url = sticker.optString("base_url");
                              JSONArray arrayList = sticker.optJSONArray("sticker_ids");

                              for (int iii = 0; i < arrayList.length(); iii++) {
                                JSONObject iiii = arrayList.optJSONObject(iii);
                                int id = iiii.optInt("sticker_ids");
                                String url = sticker.optString(base_url + id + "/256.png");

                                items.add(new StickerItem(url, id));
                              }
                            }
                          }
                          StickAdapter adapter = new StickAdapter(getApplicationContext(), items);
                          ListView.setAdapter(adapter);
                        }
                      });

                } catch (Exception e) {
                  e.printStackTrace();
                }
              }
            })
        .start();
  }
Beispiel #4
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.friends, container, false);
    final ListView ListView = (ListView) rootView.findViewById(R.id.ListView);

    colors =
        getActivity()
            .getSharedPreferences("com.kanefron5.vktest_preferences", getActivity().MODE_PRIVATE);
    account.restore(getActivity());
    // Создаем API, Если есть токен
    if (account.access_token != null) {
      api = Api.get();
    } else {
      Toast.makeText(getActivity(), R.string.fail, Toast.LENGTH_LONG).show();
    }
    // Усе! Дальше можно отправлять запросы на сервер
    // Получим список диалогов
    new Thread(
            new Runnable() {
              @Override
              public void run() {
                try {

                  final ArrayList<DialogsItem> items = new ArrayList<>();
                  ArrayList<VKUser> Userss =
                      api.getFriends(account.user_id, "hints", 0, null, null);
                  ArrayList<Long> uidsList = new ArrayList<>();
                  for (VKUser user : Userss) {
                    uidsList.add(user.user_id);
                  }
                  /* Думаю тут понятно, нам нужен ID, Заносим в лист,
                  что бы потом вытащить инфу и пользователе.*/
                  ArrayList<VKFullUser> apiProfiles =
                      api.getProfiles(
                          uidsList, null, "nickname, photo_200, online", null, null, null);
                  /* Получаем информацию и пользователях по их ID
                  Ну и все почти */
                  for (int i = 0; i < apiProfiles.size(); i++) {
                    VKFullUser user = apiProfiles.get(i);
                    VKUser message = Userss.get(i);
                    items.add(
                        new DialogsItem(
                            user.uid,
                            user.uid,
                            user.first_name + " " + user.last_name,
                            user.photo_200,
                            user.online));
                  }

                  getActivity()
                      .runOnUiThread(
                          new Runnable() {
                            @Override
                            public void run() {
                              DialogsAdapter adapter =
                                  new DialogsAdapter(getActivity().getApplicationContext(), items);
                              ListView.setAdapter(adapter);
                            }
                          });

                } catch (Exception e) {
                  e.printStackTrace();
                }
              }
            })
        .start();
    // Как-то так!
    return rootView;
  }