第三方登入,地圖,
阿新 • • 發佈:2018-12-10
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.squareup.picasso:picasso:2.3.2'
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
implementation 'com.google.code.gson:gson:2.2.4'
implementation 'com.squareup.okhttp3:logging-interceptor:3.11.0'
implementation 'com.github.bumptech.glide:glide:3.7.0'
//3D地圖so及jar
implementation 'com.amap.api:3dmap:latest.integration'
//定位功能
implementation 'com.amap.api:location:latest.integration'
//搜尋功能
implementation 'com.amap.api:search:latest.integration'
implementation files('libs/umeng-share-core-6.9.3.jar')
以上是依賴
==========================mainactivity=====================================
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.example.dell.myapplicationcl.di.icontract;
import com.example.dell.myapplicationcl.di.presenterimp;
import com.squareup.picasso.Picasso;
import com.umeng.socialize.UMAuthListener;
import com.umeng.socialize.UMShareAPI;
import com.umeng.socialize.bean.SHARE_MEDIA;
import java.util.List;
import java.util.Map;
import adapter.Adapter;
import bean.Bean;
public class MainActivity extends AppCompatActivity implements icontract.iview {
private RecyclerView recy_view;
private com.example.dell.myapplicationcl.di.presenterimp presenterimp;
private TextView dingwei;
private ImageView img;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
recy_view = findViewById(R.id.recl_view);
dingwei = findViewById(R.id.dingwei);
img = findViewById(R.id.img);
presenterimp = new presenterimp();
presenterimp.attchview(this);
presenterimp.requestinfo();
dingwei.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, dingwei.class);
startActivity(intent);
}
});
img.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
UMShareAPI.get(MainActivity.this).getPlatformInfo(MainActivity.this, SHARE_MEDIA.QQ, authListener);
}
UMAuthListener authListener = new UMAuthListener() {
/**
* @desc 授權開始的回撥
* @param platform 平臺名稱
*/
@Override
public void onStart(SHARE_MEDIA platform) {
}
/**
* @desc 授權成功的回撥
* @param platform 平臺名稱
* @param action 行為序號,開發者用不上
* @param data 使用者資料返回
*/
@Override
public void onComplete(SHARE_MEDIA platform, int action, Map<String, String> data) {
Toast.makeText(MainActivity.this, "成功了", Toast.LENGTH_LONG).show();
Picasso.with(MainActivity.this).load(data.get("iconurl")).into(img);
}
/**
* @desc 授權失敗的回撥
* @param platform 平臺名稱
* @param action 行為序號,開發者用不上
* @param t 錯誤原因
*/
@Override
public void onError(SHARE_MEDIA platform, int action, Throwable t) {
Toast.makeText(MainActivity.this, "失敗:" + t.getMessage(), Toast.LENGTH_LONG).show();
}
/**
* @desc 授權取消的回撥
* @param platform 平臺名稱
* @param action 行為序號,開發者用不上
*/
@Override
public void onCancel(SHARE_MEDIA platform, int action) {
Toast.makeText(MainActivity.this, "取消了", Toast.LENGTH_LONG).show();
}
};
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
UMShareAPI.get(this).onActivityResult(requestCode, resultCode, data);
}
@Override
protected void onDestroy() {
super.onDestroy();
presenterimp.datachview(this);
}
@Override
public void data(final List<Bean.DataBean> s) {
runOnUiThread(new Runnable() {
@Override
public void run() {
// Toast.makeText(MainActivity.this, "s:" + s, Toast.LENGTH_SHORT).show();
LinearLayoutManager manager = new LinearLayoutManager(MainActivity.this, LinearLayoutManager.VERTICAL, false);
recy_view.setLayoutManager(manager);
Adapter adapter = new Adapter(MainActivity.this,s);
recy_view.setAdapter(adapter);
}
});
}
}
===================dingweiActivity=================================================
package com.example.dell.myapplicationcl;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.amap.api.maps.AMap;
import com.amap.api.maps.MapView;
public class dingwei extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dingwei);
MapView mapView = (MapView) findViewById(R.id.map);
mapView.onCreate(savedInstanceState);// 此方法必須重寫
AMap aMap = mapView.getMap();
}
}