リファクタ
This commit is contained in:
parent
e6bf85dd3b
commit
cd656322d1
@ -9,8 +9,8 @@ android {
|
||||
applicationId "jp.juggler.subwaytooter"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 25
|
||||
versionCode 121
|
||||
versionName "1.2.1"
|
||||
versionCode 122
|
||||
versionName "1.2.2"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,6 @@ import java.io.InputStream;
|
||||
import jp.juggler.subwaytooter.api.TootApiClient;
|
||||
import jp.juggler.subwaytooter.api.TootApiResult;
|
||||
import jp.juggler.subwaytooter.api.entity.TootAccount;
|
||||
import jp.juggler.subwaytooter.api.entity.TootInstance;
|
||||
import jp.juggler.subwaytooter.api.entity.TootStatus;
|
||||
import jp.juggler.subwaytooter.dialog.ActionsDialog;
|
||||
import jp.juggler.subwaytooter.table.AcctColor;
|
||||
@ -92,8 +91,6 @@ public class ActAccountSetting extends AppCompatActivity
|
||||
|
||||
initializeProfile();
|
||||
|
||||
initializeInstanceInformation();
|
||||
|
||||
btnOpenBrowser.setText( getString( R.string.open_instance_website, account.host ) );
|
||||
}
|
||||
|
||||
@ -1087,75 +1084,5 @@ public class ActAccountSetting extends AppCompatActivity
|
||||
}.executeOnExecutor( App1.task_executor );
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void initializeInstanceInformation(){
|
||||
|
||||
loadInstanceInformation();
|
||||
}
|
||||
|
||||
void loadInstanceInformation(){
|
||||
// サーバから情報をロードする
|
||||
|
||||
final ProgressDialog progress = new ProgressDialog( this );
|
||||
|
||||
final AsyncTask< Void, Void, TootApiResult > task = new AsyncTask< Void, Void, TootApiResult >() {
|
||||
|
||||
TootInstance data;
|
||||
|
||||
@Override protected TootApiResult doInBackground( Void... params ){
|
||||
TootApiClient client = new TootApiClient( ActAccountSetting.this, new TootApiClient.Callback() {
|
||||
@Override public boolean isApiCancelled(){
|
||||
return isCancelled();
|
||||
}
|
||||
|
||||
@Override public void publishApiProgress( final String s ){
|
||||
}
|
||||
} );
|
||||
client.setAccount( account );
|
||||
|
||||
TootApiResult result = client.request( "/api/v1/instance" );
|
||||
if( result != null && result.object != null ){
|
||||
data = TootInstance.parse( result.object );
|
||||
if( data == null ) return new TootApiResult( "TootInstance parse failed." );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCancelled( TootApiResult result ){
|
||||
super.onPostExecute( result );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute( TootApiResult result ){
|
||||
try{
|
||||
progress.dismiss();
|
||||
}catch( Throwable ignored ){
|
||||
}
|
||||
if( result == null ){
|
||||
// cancelled.
|
||||
}else if( data != null ){
|
||||
showInstanceInformation( data );
|
||||
}else{
|
||||
Utils.showToast( ActAccountSetting.this, true, result.error );
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
task.executeOnExecutor( App1.task_executor );
|
||||
progress.setIndeterminate( true );
|
||||
progress.setOnDismissListener( new DialogInterface.OnDismissListener() {
|
||||
@Override public void onDismiss( DialogInterface dialog ){
|
||||
task.cancel( true );
|
||||
}
|
||||
} );
|
||||
progress.show();
|
||||
}
|
||||
|
||||
private void showInstanceInformation( TootInstance data ){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,6 @@ class HeaderViewHolderProfile extends HeaderViewHolderBase implements View.OnCli
|
||||
|
||||
showColor();
|
||||
|
||||
|
||||
if( who == null ){
|
||||
tvCreated.setText( "" );
|
||||
ivBackground.setImageDrawable( null );
|
||||
|
@ -28,7 +28,6 @@ public class DlgDraftPicker
|
||||
, DialogInterface.OnDismissListener
|
||||
{
|
||||
|
||||
|
||||
public interface Callback {
|
||||
void onDraftSelected( JSONObject draft );
|
||||
}
|
||||
@ -54,7 +53,8 @@ public class DlgDraftPicker
|
||||
}
|
||||
}
|
||||
|
||||
@Override public boolean onItemLongClick( AdapterView< ? > parent, View view, int position, long id ){
|
||||
@Override
|
||||
public boolean onItemLongClick( AdapterView< ? > parent, View view, int position, long id ){
|
||||
|
||||
PostDraft draft = getPostDraft( position );
|
||||
if( draft != null ){
|
||||
@ -102,7 +102,6 @@ public class DlgDraftPicker
|
||||
;
|
||||
dialog.setOnDismissListener( this );
|
||||
|
||||
|
||||
dialog.show();
|
||||
|
||||
reload();
|
||||
@ -123,6 +122,7 @@ public class DlgDraftPicker
|
||||
@Override protected void onCancelled( Cursor cursor ){
|
||||
super.onCancelled( cursor );
|
||||
}
|
||||
|
||||
@Override protected void onPostExecute( Cursor cursor ){
|
||||
if( ! dialog.isShowing() ){
|
||||
// dialog is already closed.
|
||||
|
Loading…
x
Reference in New Issue
Block a user