repo_name
stringlengths
7
104
file_path
stringlengths
13
198
context
stringlengths
67
7.15k
import_statement
stringlengths
16
4.43k
code
stringlengths
40
6.98k
prompt
stringlengths
227
8.27k
next_line
stringlengths
8
795
tresorit/ZeroKit-Android-SDK
sample/src/main/java/com/tresorit/zerokitsdk/component/EncryptComponent.java
// Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/EncryptFragment.java // public class EncryptFragment extends Fragment { // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // EncryptViewModel viewModel; // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // EventBus eventBus; // // @SuppressWarnings("WeakerAccess") // FragmentEncryptBinding binding; // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // binding = FragmentEncryptBinding.inflate(inflater, container, false); // DaggerEncryptComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).encryptModule(new EncryptModule(getChildFragmentManager())).build().inject(this); // binding.setViewmodel(viewModel); // binding.pager.setPagingEnabled(false); // return binding.getRoot(); // } // // @Override // public void onStart() { // super.onStart(); // eventBus.register(this); // } // // @Override // public void onStop() { // super.onStop(); // eventBus.unregister(this); // } // // @Subscribe // @SuppressWarnings("unused") // public void onEvent(@SuppressWarnings("UnusedParameters") CreateTresorFinishedMessage message){ // binding.pager.setPagingEnabled(true); // binding.pager.postDelayed(new Runnable() { // @Override // public void run() { // binding.pager.setCurrentItem(1); // } // }, 500); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/EncryptModule.java // @Module // public class EncryptModule { // // private final FragmentManager fragmentManager; // // public EncryptModule(FragmentManager fragmentManager) { // this.fragmentManager = fragmentManager; // } // // @Provides // @ActivityScope // public EncryptViewModel provideEncryptViewModel(Context context) { // return new EncryptViewModel(context, fragmentManager); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/viewmodel/EncryptViewModel.java // public class EncryptViewModel extends BaseObservable { // // @SuppressWarnings("WeakerAccess") // public final EncryptPagerAdapter pagerAdapter; // @SuppressWarnings("WeakerAccess") // public final ViewPager.OnPageChangeListener pageChangeListener; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Drawable> drawableDot1; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Drawable> drawableDot2; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Drawable> drawableDot3; // // // public EncryptViewModel(final Context context, FragmentManager fragmentManager) { // pagerAdapter = new EncryptPagerAdapter(context, fragmentManager); // pageChangeListener = new ViewPager.SimpleOnPageChangeListener() { // // @Override // public void onPageSelected(int position) { // drawableDot1.set(context.getResources().getDrawable(position == 0 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot)); // drawableDot2.set(context.getResources().getDrawable(position == 1 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot)); // drawableDot3.set(context.getResources().getDrawable(position == 2 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot)); // } // // }; // // drawableDot1 = new ObservableField<>(context.getResources().getDrawable(R.drawable.selecteditem_dot)); // drawableDot2 = new ObservableField<>(context.getResources().getDrawable(R.drawable.nonselecteditem_dot)); // drawableDot3 = new ObservableField<>(context.getResources().getDrawable(R.drawable.nonselecteditem_dot)); // } // // // // }
import com.tresorit.zerokitsdk.fragment.EncryptFragment; import com.tresorit.zerokitsdk.module.EncryptModule; import com.tresorit.zerokitsdk.scopes.ActivityScope; import com.tresorit.zerokitsdk.viewmodel.EncryptViewModel; import dagger.Component;
package com.tresorit.zerokitsdk.component; @ActivityScope @Component( modules = { EncryptModule.class }, dependencies = { ApplicationComponent.class } ) public interface EncryptComponent { void inject(EncryptFragment fragment);
// Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/EncryptFragment.java // public class EncryptFragment extends Fragment { // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // EncryptViewModel viewModel; // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // EventBus eventBus; // // @SuppressWarnings("WeakerAccess") // FragmentEncryptBinding binding; // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // binding = FragmentEncryptBinding.inflate(inflater, container, false); // DaggerEncryptComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).encryptModule(new EncryptModule(getChildFragmentManager())).build().inject(this); // binding.setViewmodel(viewModel); // binding.pager.setPagingEnabled(false); // return binding.getRoot(); // } // // @Override // public void onStart() { // super.onStart(); // eventBus.register(this); // } // // @Override // public void onStop() { // super.onStop(); // eventBus.unregister(this); // } // // @Subscribe // @SuppressWarnings("unused") // public void onEvent(@SuppressWarnings("UnusedParameters") CreateTresorFinishedMessage message){ // binding.pager.setPagingEnabled(true); // binding.pager.postDelayed(new Runnable() { // @Override // public void run() { // binding.pager.setCurrentItem(1); // } // }, 500); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/EncryptModule.java // @Module // public class EncryptModule { // // private final FragmentManager fragmentManager; // // public EncryptModule(FragmentManager fragmentManager) { // this.fragmentManager = fragmentManager; // } // // @Provides // @ActivityScope // public EncryptViewModel provideEncryptViewModel(Context context) { // return new EncryptViewModel(context, fragmentManager); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/viewmodel/EncryptViewModel.java // public class EncryptViewModel extends BaseObservable { // // @SuppressWarnings("WeakerAccess") // public final EncryptPagerAdapter pagerAdapter; // @SuppressWarnings("WeakerAccess") // public final ViewPager.OnPageChangeListener pageChangeListener; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Drawable> drawableDot1; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Drawable> drawableDot2; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Drawable> drawableDot3; // // // public EncryptViewModel(final Context context, FragmentManager fragmentManager) { // pagerAdapter = new EncryptPagerAdapter(context, fragmentManager); // pageChangeListener = new ViewPager.SimpleOnPageChangeListener() { // // @Override // public void onPageSelected(int position) { // drawableDot1.set(context.getResources().getDrawable(position == 0 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot)); // drawableDot2.set(context.getResources().getDrawable(position == 1 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot)); // drawableDot3.set(context.getResources().getDrawable(position == 2 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot)); // } // // }; // // drawableDot1 = new ObservableField<>(context.getResources().getDrawable(R.drawable.selecteditem_dot)); // drawableDot2 = new ObservableField<>(context.getResources().getDrawable(R.drawable.nonselecteditem_dot)); // drawableDot3 = new ObservableField<>(context.getResources().getDrawable(R.drawable.nonselecteditem_dot)); // } // // // // } // Path: sample/src/main/java/com/tresorit/zerokitsdk/component/EncryptComponent.java import com.tresorit.zerokitsdk.fragment.EncryptFragment; import com.tresorit.zerokitsdk.module.EncryptModule; import com.tresorit.zerokitsdk.scopes.ActivityScope; import com.tresorit.zerokitsdk.viewmodel.EncryptViewModel; import dagger.Component; package com.tresorit.zerokitsdk.component; @ActivityScope @Component( modules = { EncryptModule.class }, dependencies = { ApplicationComponent.class } ) public interface EncryptComponent { void inject(EncryptFragment fragment);
EncryptViewModel viewmodel();
tresorit/ZeroKit-Android-SDK
zerokit/src/main/java/com/tresorit/zerokit/response/ResponseZerokitError.java
// Path: zerokit/src/main/java/com/tresorit/zerokit/util/JSONObject.java // public class JSONObject { // // private org.json.JSONObject jsonObject; // // public JSONObject() { // jsonObject = new org.json.JSONObject(); // } // // public JSONObject(String json) { // try { // jsonObject = new org.json.JSONObject(json); // } catch (JSONException e) { // //e.printStackTrace(); // jsonObject = new org.json.JSONObject(); // } // } // // public org.json.JSONObject getJSONObject(String name) { // if (jsonObject != null) // try { // return jsonObject.getJSONObject(name); // } catch (JSONException e) { // //e.printStackTrace(); // } // return new org.json.JSONObject(); // } // // // public String getString(String name) { // if (jsonObject != null) // try { // return jsonObject.getString(name); // } catch (JSONException e) { // //e.printStackTrace(); // } // return ""; // } // // public double getDouble(String name) { // if (jsonObject != null) // try { // return jsonObject.getDouble(name); // } catch (JSONException e) { // //e.printStackTrace(); // } // return 0; // } // // public int getInt(String name) { // if (jsonObject != null) // try { // return jsonObject.getInt(name); // } catch (JSONException e) { // //e.printStackTrace(); // } // return 0; // } // // public List<String> getStringArray(String name) { // if (jsonObject != null) // try { // JSONArray jsonArray = jsonObject.getJSONArray(name); // List<String> result = new ArrayList<>(); // for (int i = 0; i < jsonArray.length(); i++) // result.add(jsonArray.getString(i)); // return result; // } catch (JSONException e) { // //e.printStackTrace(); // } // return new ArrayList<>(); // } // // public JSONObject put(String name, Object value) { // if (jsonObject != null) // try { // jsonObject.put(name, value); // } catch (JSONException e) { // //e.printStackTrace(); // } // return this; // } // // @Override // public String toString() { // return jsonObject != null ? jsonObject.toString() : ""; // } // } // // Path: common/src/main/java/com/tresorit/zerokit/util/ZerokitJson.java // public abstract class ZerokitJson { // // public abstract <T extends ZerokitJson> T parse(String json); // // }
import com.tresorit.zerokit.util.JSONObject; import com.tresorit.zerokit.util.ZerokitJson;
public ResponseZerokitError() { this("", "", "", ""); } public void setDescription(String description) { this.description = description; } public void setMessage(String message) { this.message = message; } public String getType() { return type; } public String getCode() { return code; } public String getMessage() { return message; } public String getDescription() { return description; } public String toJSON() {
// Path: zerokit/src/main/java/com/tresorit/zerokit/util/JSONObject.java // public class JSONObject { // // private org.json.JSONObject jsonObject; // // public JSONObject() { // jsonObject = new org.json.JSONObject(); // } // // public JSONObject(String json) { // try { // jsonObject = new org.json.JSONObject(json); // } catch (JSONException e) { // //e.printStackTrace(); // jsonObject = new org.json.JSONObject(); // } // } // // public org.json.JSONObject getJSONObject(String name) { // if (jsonObject != null) // try { // return jsonObject.getJSONObject(name); // } catch (JSONException e) { // //e.printStackTrace(); // } // return new org.json.JSONObject(); // } // // // public String getString(String name) { // if (jsonObject != null) // try { // return jsonObject.getString(name); // } catch (JSONException e) { // //e.printStackTrace(); // } // return ""; // } // // public double getDouble(String name) { // if (jsonObject != null) // try { // return jsonObject.getDouble(name); // } catch (JSONException e) { // //e.printStackTrace(); // } // return 0; // } // // public int getInt(String name) { // if (jsonObject != null) // try { // return jsonObject.getInt(name); // } catch (JSONException e) { // //e.printStackTrace(); // } // return 0; // } // // public List<String> getStringArray(String name) { // if (jsonObject != null) // try { // JSONArray jsonArray = jsonObject.getJSONArray(name); // List<String> result = new ArrayList<>(); // for (int i = 0; i < jsonArray.length(); i++) // result.add(jsonArray.getString(i)); // return result; // } catch (JSONException e) { // //e.printStackTrace(); // } // return new ArrayList<>(); // } // // public JSONObject put(String name, Object value) { // if (jsonObject != null) // try { // jsonObject.put(name, value); // } catch (JSONException e) { // //e.printStackTrace(); // } // return this; // } // // @Override // public String toString() { // return jsonObject != null ? jsonObject.toString() : ""; // } // } // // Path: common/src/main/java/com/tresorit/zerokit/util/ZerokitJson.java // public abstract class ZerokitJson { // // public abstract <T extends ZerokitJson> T parse(String json); // // } // Path: zerokit/src/main/java/com/tresorit/zerokit/response/ResponseZerokitError.java import com.tresorit.zerokit.util.JSONObject; import com.tresorit.zerokit.util.ZerokitJson; public ResponseZerokitError() { this("", "", "", ""); } public void setDescription(String description) { this.description = description; } public void setMessage(String message) { this.message = message; } public String getType() { return type; } public String getCode() { return code; } public String getMessage() { return message; } public String getDescription() { return description; } public String toJSON() {
JSONObject jsonObject = new JSONObject();
tresorit/ZeroKit-Android-SDK
sample/src/main/java/com/tresorit/zerokitsdk/fragment/EncryptFragment.java
// Path: sample/src/main/java/com/tresorit/zerokitsdk/ZerokitApplication.java // public class ZerokitApplication extends Application { // // private ApplicationComponent component; // // public static ZerokitApplication get(Context context) { // return (ZerokitApplication) context.getApplicationContext(); // } // // @Override // public void onCreate() { // super.onCreate(); // component = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .adminApiModule(new AdminApiModule(BuildConfig.APP_BACKEND, BuildConfig.CLIENT_ID)) // .build(); // } // // public ApplicationComponent component() { // return component; // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/message/CreateTresorFinishedMessage.java // public class CreateTresorFinishedMessage { // private final String tresorId; // // public CreateTresorFinishedMessage(String tresorId) { // this.tresorId = tresorId; // } // // public String getTresorId() { // return tresorId; // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/EncryptModule.java // @Module // public class EncryptModule { // // private final FragmentManager fragmentManager; // // public EncryptModule(FragmentManager fragmentManager) { // this.fragmentManager = fragmentManager; // } // // @Provides // @ActivityScope // public EncryptViewModel provideEncryptViewModel(Context context) { // return new EncryptViewModel(context, fragmentManager); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/viewmodel/EncryptViewModel.java // public class EncryptViewModel extends BaseObservable { // // @SuppressWarnings("WeakerAccess") // public final EncryptPagerAdapter pagerAdapter; // @SuppressWarnings("WeakerAccess") // public final ViewPager.OnPageChangeListener pageChangeListener; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Drawable> drawableDot1; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Drawable> drawableDot2; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Drawable> drawableDot3; // // // public EncryptViewModel(final Context context, FragmentManager fragmentManager) { // pagerAdapter = new EncryptPagerAdapter(context, fragmentManager); // pageChangeListener = new ViewPager.SimpleOnPageChangeListener() { // // @Override // public void onPageSelected(int position) { // drawableDot1.set(context.getResources().getDrawable(position == 0 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot)); // drawableDot2.set(context.getResources().getDrawable(position == 1 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot)); // drawableDot3.set(context.getResources().getDrawable(position == 2 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot)); // } // // }; // // drawableDot1 = new ObservableField<>(context.getResources().getDrawable(R.drawable.selecteditem_dot)); // drawableDot2 = new ObservableField<>(context.getResources().getDrawable(R.drawable.nonselecteditem_dot)); // drawableDot3 = new ObservableField<>(context.getResources().getDrawable(R.drawable.nonselecteditem_dot)); // } // // // // }
import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.tresorit.zerokitsdk.ZerokitApplication; import com.tresorit.zerokitsdk.component.DaggerEncryptComponent; import com.tresorit.zerokitsdk.databinding.FragmentEncryptBinding; import com.tresorit.zerokitsdk.message.CreateTresorFinishedMessage; import com.tresorit.zerokitsdk.module.EncryptModule; import com.tresorit.zerokitsdk.viewmodel.EncryptViewModel; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import javax.inject.Inject;
package com.tresorit.zerokitsdk.fragment; public class EncryptFragment extends Fragment { @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) @Inject
// Path: sample/src/main/java/com/tresorit/zerokitsdk/ZerokitApplication.java // public class ZerokitApplication extends Application { // // private ApplicationComponent component; // // public static ZerokitApplication get(Context context) { // return (ZerokitApplication) context.getApplicationContext(); // } // // @Override // public void onCreate() { // super.onCreate(); // component = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .adminApiModule(new AdminApiModule(BuildConfig.APP_BACKEND, BuildConfig.CLIENT_ID)) // .build(); // } // // public ApplicationComponent component() { // return component; // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/message/CreateTresorFinishedMessage.java // public class CreateTresorFinishedMessage { // private final String tresorId; // // public CreateTresorFinishedMessage(String tresorId) { // this.tresorId = tresorId; // } // // public String getTresorId() { // return tresorId; // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/EncryptModule.java // @Module // public class EncryptModule { // // private final FragmentManager fragmentManager; // // public EncryptModule(FragmentManager fragmentManager) { // this.fragmentManager = fragmentManager; // } // // @Provides // @ActivityScope // public EncryptViewModel provideEncryptViewModel(Context context) { // return new EncryptViewModel(context, fragmentManager); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/viewmodel/EncryptViewModel.java // public class EncryptViewModel extends BaseObservable { // // @SuppressWarnings("WeakerAccess") // public final EncryptPagerAdapter pagerAdapter; // @SuppressWarnings("WeakerAccess") // public final ViewPager.OnPageChangeListener pageChangeListener; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Drawable> drawableDot1; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Drawable> drawableDot2; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Drawable> drawableDot3; // // // public EncryptViewModel(final Context context, FragmentManager fragmentManager) { // pagerAdapter = new EncryptPagerAdapter(context, fragmentManager); // pageChangeListener = new ViewPager.SimpleOnPageChangeListener() { // // @Override // public void onPageSelected(int position) { // drawableDot1.set(context.getResources().getDrawable(position == 0 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot)); // drawableDot2.set(context.getResources().getDrawable(position == 1 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot)); // drawableDot3.set(context.getResources().getDrawable(position == 2 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot)); // } // // }; // // drawableDot1 = new ObservableField<>(context.getResources().getDrawable(R.drawable.selecteditem_dot)); // drawableDot2 = new ObservableField<>(context.getResources().getDrawable(R.drawable.nonselecteditem_dot)); // drawableDot3 = new ObservableField<>(context.getResources().getDrawable(R.drawable.nonselecteditem_dot)); // } // // // // } // Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/EncryptFragment.java import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.tresorit.zerokitsdk.ZerokitApplication; import com.tresorit.zerokitsdk.component.DaggerEncryptComponent; import com.tresorit.zerokitsdk.databinding.FragmentEncryptBinding; import com.tresorit.zerokitsdk.message.CreateTresorFinishedMessage; import com.tresorit.zerokitsdk.module.EncryptModule; import com.tresorit.zerokitsdk.viewmodel.EncryptViewModel; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import javax.inject.Inject; package com.tresorit.zerokitsdk.fragment; public class EncryptFragment extends Fragment { @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) @Inject
EncryptViewModel viewModel;
tresorit/ZeroKit-Android-SDK
sample/src/main/java/com/tresorit/zerokitsdk/fragment/EncryptFragment.java
// Path: sample/src/main/java/com/tresorit/zerokitsdk/ZerokitApplication.java // public class ZerokitApplication extends Application { // // private ApplicationComponent component; // // public static ZerokitApplication get(Context context) { // return (ZerokitApplication) context.getApplicationContext(); // } // // @Override // public void onCreate() { // super.onCreate(); // component = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .adminApiModule(new AdminApiModule(BuildConfig.APP_BACKEND, BuildConfig.CLIENT_ID)) // .build(); // } // // public ApplicationComponent component() { // return component; // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/message/CreateTresorFinishedMessage.java // public class CreateTresorFinishedMessage { // private final String tresorId; // // public CreateTresorFinishedMessage(String tresorId) { // this.tresorId = tresorId; // } // // public String getTresorId() { // return tresorId; // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/EncryptModule.java // @Module // public class EncryptModule { // // private final FragmentManager fragmentManager; // // public EncryptModule(FragmentManager fragmentManager) { // this.fragmentManager = fragmentManager; // } // // @Provides // @ActivityScope // public EncryptViewModel provideEncryptViewModel(Context context) { // return new EncryptViewModel(context, fragmentManager); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/viewmodel/EncryptViewModel.java // public class EncryptViewModel extends BaseObservable { // // @SuppressWarnings("WeakerAccess") // public final EncryptPagerAdapter pagerAdapter; // @SuppressWarnings("WeakerAccess") // public final ViewPager.OnPageChangeListener pageChangeListener; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Drawable> drawableDot1; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Drawable> drawableDot2; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Drawable> drawableDot3; // // // public EncryptViewModel(final Context context, FragmentManager fragmentManager) { // pagerAdapter = new EncryptPagerAdapter(context, fragmentManager); // pageChangeListener = new ViewPager.SimpleOnPageChangeListener() { // // @Override // public void onPageSelected(int position) { // drawableDot1.set(context.getResources().getDrawable(position == 0 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot)); // drawableDot2.set(context.getResources().getDrawable(position == 1 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot)); // drawableDot3.set(context.getResources().getDrawable(position == 2 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot)); // } // // }; // // drawableDot1 = new ObservableField<>(context.getResources().getDrawable(R.drawable.selecteditem_dot)); // drawableDot2 = new ObservableField<>(context.getResources().getDrawable(R.drawable.nonselecteditem_dot)); // drawableDot3 = new ObservableField<>(context.getResources().getDrawable(R.drawable.nonselecteditem_dot)); // } // // // // }
import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.tresorit.zerokitsdk.ZerokitApplication; import com.tresorit.zerokitsdk.component.DaggerEncryptComponent; import com.tresorit.zerokitsdk.databinding.FragmentEncryptBinding; import com.tresorit.zerokitsdk.message.CreateTresorFinishedMessage; import com.tresorit.zerokitsdk.module.EncryptModule; import com.tresorit.zerokitsdk.viewmodel.EncryptViewModel; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import javax.inject.Inject;
package com.tresorit.zerokitsdk.fragment; public class EncryptFragment extends Fragment { @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) @Inject EncryptViewModel viewModel; @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) @Inject EventBus eventBus; @SuppressWarnings("WeakerAccess") FragmentEncryptBinding binding; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { binding = FragmentEncryptBinding.inflate(inflater, container, false);
// Path: sample/src/main/java/com/tresorit/zerokitsdk/ZerokitApplication.java // public class ZerokitApplication extends Application { // // private ApplicationComponent component; // // public static ZerokitApplication get(Context context) { // return (ZerokitApplication) context.getApplicationContext(); // } // // @Override // public void onCreate() { // super.onCreate(); // component = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .adminApiModule(new AdminApiModule(BuildConfig.APP_BACKEND, BuildConfig.CLIENT_ID)) // .build(); // } // // public ApplicationComponent component() { // return component; // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/message/CreateTresorFinishedMessage.java // public class CreateTresorFinishedMessage { // private final String tresorId; // // public CreateTresorFinishedMessage(String tresorId) { // this.tresorId = tresorId; // } // // public String getTresorId() { // return tresorId; // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/EncryptModule.java // @Module // public class EncryptModule { // // private final FragmentManager fragmentManager; // // public EncryptModule(FragmentManager fragmentManager) { // this.fragmentManager = fragmentManager; // } // // @Provides // @ActivityScope // public EncryptViewModel provideEncryptViewModel(Context context) { // return new EncryptViewModel(context, fragmentManager); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/viewmodel/EncryptViewModel.java // public class EncryptViewModel extends BaseObservable { // // @SuppressWarnings("WeakerAccess") // public final EncryptPagerAdapter pagerAdapter; // @SuppressWarnings("WeakerAccess") // public final ViewPager.OnPageChangeListener pageChangeListener; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Drawable> drawableDot1; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Drawable> drawableDot2; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Drawable> drawableDot3; // // // public EncryptViewModel(final Context context, FragmentManager fragmentManager) { // pagerAdapter = new EncryptPagerAdapter(context, fragmentManager); // pageChangeListener = new ViewPager.SimpleOnPageChangeListener() { // // @Override // public void onPageSelected(int position) { // drawableDot1.set(context.getResources().getDrawable(position == 0 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot)); // drawableDot2.set(context.getResources().getDrawable(position == 1 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot)); // drawableDot3.set(context.getResources().getDrawable(position == 2 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot)); // } // // }; // // drawableDot1 = new ObservableField<>(context.getResources().getDrawable(R.drawable.selecteditem_dot)); // drawableDot2 = new ObservableField<>(context.getResources().getDrawable(R.drawable.nonselecteditem_dot)); // drawableDot3 = new ObservableField<>(context.getResources().getDrawable(R.drawable.nonselecteditem_dot)); // } // // // // } // Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/EncryptFragment.java import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.tresorit.zerokitsdk.ZerokitApplication; import com.tresorit.zerokitsdk.component.DaggerEncryptComponent; import com.tresorit.zerokitsdk.databinding.FragmentEncryptBinding; import com.tresorit.zerokitsdk.message.CreateTresorFinishedMessage; import com.tresorit.zerokitsdk.module.EncryptModule; import com.tresorit.zerokitsdk.viewmodel.EncryptViewModel; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import javax.inject.Inject; package com.tresorit.zerokitsdk.fragment; public class EncryptFragment extends Fragment { @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) @Inject EncryptViewModel viewModel; @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) @Inject EventBus eventBus; @SuppressWarnings("WeakerAccess") FragmentEncryptBinding binding; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { binding = FragmentEncryptBinding.inflate(inflater, container, false);
DaggerEncryptComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).encryptModule(new EncryptModule(getChildFragmentManager())).build().inject(this);
tresorit/ZeroKit-Android-SDK
sample/src/main/java/com/tresorit/zerokitsdk/fragment/EncryptFragment.java
// Path: sample/src/main/java/com/tresorit/zerokitsdk/ZerokitApplication.java // public class ZerokitApplication extends Application { // // private ApplicationComponent component; // // public static ZerokitApplication get(Context context) { // return (ZerokitApplication) context.getApplicationContext(); // } // // @Override // public void onCreate() { // super.onCreate(); // component = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .adminApiModule(new AdminApiModule(BuildConfig.APP_BACKEND, BuildConfig.CLIENT_ID)) // .build(); // } // // public ApplicationComponent component() { // return component; // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/message/CreateTresorFinishedMessage.java // public class CreateTresorFinishedMessage { // private final String tresorId; // // public CreateTresorFinishedMessage(String tresorId) { // this.tresorId = tresorId; // } // // public String getTresorId() { // return tresorId; // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/EncryptModule.java // @Module // public class EncryptModule { // // private final FragmentManager fragmentManager; // // public EncryptModule(FragmentManager fragmentManager) { // this.fragmentManager = fragmentManager; // } // // @Provides // @ActivityScope // public EncryptViewModel provideEncryptViewModel(Context context) { // return new EncryptViewModel(context, fragmentManager); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/viewmodel/EncryptViewModel.java // public class EncryptViewModel extends BaseObservable { // // @SuppressWarnings("WeakerAccess") // public final EncryptPagerAdapter pagerAdapter; // @SuppressWarnings("WeakerAccess") // public final ViewPager.OnPageChangeListener pageChangeListener; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Drawable> drawableDot1; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Drawable> drawableDot2; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Drawable> drawableDot3; // // // public EncryptViewModel(final Context context, FragmentManager fragmentManager) { // pagerAdapter = new EncryptPagerAdapter(context, fragmentManager); // pageChangeListener = new ViewPager.SimpleOnPageChangeListener() { // // @Override // public void onPageSelected(int position) { // drawableDot1.set(context.getResources().getDrawable(position == 0 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot)); // drawableDot2.set(context.getResources().getDrawable(position == 1 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot)); // drawableDot3.set(context.getResources().getDrawable(position == 2 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot)); // } // // }; // // drawableDot1 = new ObservableField<>(context.getResources().getDrawable(R.drawable.selecteditem_dot)); // drawableDot2 = new ObservableField<>(context.getResources().getDrawable(R.drawable.nonselecteditem_dot)); // drawableDot3 = new ObservableField<>(context.getResources().getDrawable(R.drawable.nonselecteditem_dot)); // } // // // // }
import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.tresorit.zerokitsdk.ZerokitApplication; import com.tresorit.zerokitsdk.component.DaggerEncryptComponent; import com.tresorit.zerokitsdk.databinding.FragmentEncryptBinding; import com.tresorit.zerokitsdk.message.CreateTresorFinishedMessage; import com.tresorit.zerokitsdk.module.EncryptModule; import com.tresorit.zerokitsdk.viewmodel.EncryptViewModel; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import javax.inject.Inject;
package com.tresorit.zerokitsdk.fragment; public class EncryptFragment extends Fragment { @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) @Inject EncryptViewModel viewModel; @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) @Inject EventBus eventBus; @SuppressWarnings("WeakerAccess") FragmentEncryptBinding binding; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { binding = FragmentEncryptBinding.inflate(inflater, container, false);
// Path: sample/src/main/java/com/tresorit/zerokitsdk/ZerokitApplication.java // public class ZerokitApplication extends Application { // // private ApplicationComponent component; // // public static ZerokitApplication get(Context context) { // return (ZerokitApplication) context.getApplicationContext(); // } // // @Override // public void onCreate() { // super.onCreate(); // component = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .adminApiModule(new AdminApiModule(BuildConfig.APP_BACKEND, BuildConfig.CLIENT_ID)) // .build(); // } // // public ApplicationComponent component() { // return component; // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/message/CreateTresorFinishedMessage.java // public class CreateTresorFinishedMessage { // private final String tresorId; // // public CreateTresorFinishedMessage(String tresorId) { // this.tresorId = tresorId; // } // // public String getTresorId() { // return tresorId; // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/EncryptModule.java // @Module // public class EncryptModule { // // private final FragmentManager fragmentManager; // // public EncryptModule(FragmentManager fragmentManager) { // this.fragmentManager = fragmentManager; // } // // @Provides // @ActivityScope // public EncryptViewModel provideEncryptViewModel(Context context) { // return new EncryptViewModel(context, fragmentManager); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/viewmodel/EncryptViewModel.java // public class EncryptViewModel extends BaseObservable { // // @SuppressWarnings("WeakerAccess") // public final EncryptPagerAdapter pagerAdapter; // @SuppressWarnings("WeakerAccess") // public final ViewPager.OnPageChangeListener pageChangeListener; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Drawable> drawableDot1; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Drawable> drawableDot2; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Drawable> drawableDot3; // // // public EncryptViewModel(final Context context, FragmentManager fragmentManager) { // pagerAdapter = new EncryptPagerAdapter(context, fragmentManager); // pageChangeListener = new ViewPager.SimpleOnPageChangeListener() { // // @Override // public void onPageSelected(int position) { // drawableDot1.set(context.getResources().getDrawable(position == 0 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot)); // drawableDot2.set(context.getResources().getDrawable(position == 1 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot)); // drawableDot3.set(context.getResources().getDrawable(position == 2 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot)); // } // // }; // // drawableDot1 = new ObservableField<>(context.getResources().getDrawable(R.drawable.selecteditem_dot)); // drawableDot2 = new ObservableField<>(context.getResources().getDrawable(R.drawable.nonselecteditem_dot)); // drawableDot3 = new ObservableField<>(context.getResources().getDrawable(R.drawable.nonselecteditem_dot)); // } // // // // } // Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/EncryptFragment.java import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.tresorit.zerokitsdk.ZerokitApplication; import com.tresorit.zerokitsdk.component.DaggerEncryptComponent; import com.tresorit.zerokitsdk.databinding.FragmentEncryptBinding; import com.tresorit.zerokitsdk.message.CreateTresorFinishedMessage; import com.tresorit.zerokitsdk.module.EncryptModule; import com.tresorit.zerokitsdk.viewmodel.EncryptViewModel; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import javax.inject.Inject; package com.tresorit.zerokitsdk.fragment; public class EncryptFragment extends Fragment { @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) @Inject EncryptViewModel viewModel; @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) @Inject EventBus eventBus; @SuppressWarnings("WeakerAccess") FragmentEncryptBinding binding; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { binding = FragmentEncryptBinding.inflate(inflater, container, false);
DaggerEncryptComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).encryptModule(new EncryptModule(getChildFragmentManager())).build().inject(this);
tresorit/ZeroKit-Android-SDK
sample/src/main/java/com/tresorit/zerokitsdk/fragment/EncryptFragment.java
// Path: sample/src/main/java/com/tresorit/zerokitsdk/ZerokitApplication.java // public class ZerokitApplication extends Application { // // private ApplicationComponent component; // // public static ZerokitApplication get(Context context) { // return (ZerokitApplication) context.getApplicationContext(); // } // // @Override // public void onCreate() { // super.onCreate(); // component = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .adminApiModule(new AdminApiModule(BuildConfig.APP_BACKEND, BuildConfig.CLIENT_ID)) // .build(); // } // // public ApplicationComponent component() { // return component; // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/message/CreateTresorFinishedMessage.java // public class CreateTresorFinishedMessage { // private final String tresorId; // // public CreateTresorFinishedMessage(String tresorId) { // this.tresorId = tresorId; // } // // public String getTresorId() { // return tresorId; // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/EncryptModule.java // @Module // public class EncryptModule { // // private final FragmentManager fragmentManager; // // public EncryptModule(FragmentManager fragmentManager) { // this.fragmentManager = fragmentManager; // } // // @Provides // @ActivityScope // public EncryptViewModel provideEncryptViewModel(Context context) { // return new EncryptViewModel(context, fragmentManager); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/viewmodel/EncryptViewModel.java // public class EncryptViewModel extends BaseObservable { // // @SuppressWarnings("WeakerAccess") // public final EncryptPagerAdapter pagerAdapter; // @SuppressWarnings("WeakerAccess") // public final ViewPager.OnPageChangeListener pageChangeListener; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Drawable> drawableDot1; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Drawable> drawableDot2; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Drawable> drawableDot3; // // // public EncryptViewModel(final Context context, FragmentManager fragmentManager) { // pagerAdapter = new EncryptPagerAdapter(context, fragmentManager); // pageChangeListener = new ViewPager.SimpleOnPageChangeListener() { // // @Override // public void onPageSelected(int position) { // drawableDot1.set(context.getResources().getDrawable(position == 0 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot)); // drawableDot2.set(context.getResources().getDrawable(position == 1 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot)); // drawableDot3.set(context.getResources().getDrawable(position == 2 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot)); // } // // }; // // drawableDot1 = new ObservableField<>(context.getResources().getDrawable(R.drawable.selecteditem_dot)); // drawableDot2 = new ObservableField<>(context.getResources().getDrawable(R.drawable.nonselecteditem_dot)); // drawableDot3 = new ObservableField<>(context.getResources().getDrawable(R.drawable.nonselecteditem_dot)); // } // // // // }
import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.tresorit.zerokitsdk.ZerokitApplication; import com.tresorit.zerokitsdk.component.DaggerEncryptComponent; import com.tresorit.zerokitsdk.databinding.FragmentEncryptBinding; import com.tresorit.zerokitsdk.message.CreateTresorFinishedMessage; import com.tresorit.zerokitsdk.module.EncryptModule; import com.tresorit.zerokitsdk.viewmodel.EncryptViewModel; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import javax.inject.Inject;
@Inject EventBus eventBus; @SuppressWarnings("WeakerAccess") FragmentEncryptBinding binding; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { binding = FragmentEncryptBinding.inflate(inflater, container, false); DaggerEncryptComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).encryptModule(new EncryptModule(getChildFragmentManager())).build().inject(this); binding.setViewmodel(viewModel); binding.pager.setPagingEnabled(false); return binding.getRoot(); } @Override public void onStart() { super.onStart(); eventBus.register(this); } @Override public void onStop() { super.onStop(); eventBus.unregister(this); } @Subscribe @SuppressWarnings("unused")
// Path: sample/src/main/java/com/tresorit/zerokitsdk/ZerokitApplication.java // public class ZerokitApplication extends Application { // // private ApplicationComponent component; // // public static ZerokitApplication get(Context context) { // return (ZerokitApplication) context.getApplicationContext(); // } // // @Override // public void onCreate() { // super.onCreate(); // component = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .adminApiModule(new AdminApiModule(BuildConfig.APP_BACKEND, BuildConfig.CLIENT_ID)) // .build(); // } // // public ApplicationComponent component() { // return component; // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/message/CreateTresorFinishedMessage.java // public class CreateTresorFinishedMessage { // private final String tresorId; // // public CreateTresorFinishedMessage(String tresorId) { // this.tresorId = tresorId; // } // // public String getTresorId() { // return tresorId; // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/EncryptModule.java // @Module // public class EncryptModule { // // private final FragmentManager fragmentManager; // // public EncryptModule(FragmentManager fragmentManager) { // this.fragmentManager = fragmentManager; // } // // @Provides // @ActivityScope // public EncryptViewModel provideEncryptViewModel(Context context) { // return new EncryptViewModel(context, fragmentManager); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/viewmodel/EncryptViewModel.java // public class EncryptViewModel extends BaseObservable { // // @SuppressWarnings("WeakerAccess") // public final EncryptPagerAdapter pagerAdapter; // @SuppressWarnings("WeakerAccess") // public final ViewPager.OnPageChangeListener pageChangeListener; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Drawable> drawableDot1; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Drawable> drawableDot2; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Drawable> drawableDot3; // // // public EncryptViewModel(final Context context, FragmentManager fragmentManager) { // pagerAdapter = new EncryptPagerAdapter(context, fragmentManager); // pageChangeListener = new ViewPager.SimpleOnPageChangeListener() { // // @Override // public void onPageSelected(int position) { // drawableDot1.set(context.getResources().getDrawable(position == 0 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot)); // drawableDot2.set(context.getResources().getDrawable(position == 1 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot)); // drawableDot3.set(context.getResources().getDrawable(position == 2 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot)); // } // // }; // // drawableDot1 = new ObservableField<>(context.getResources().getDrawable(R.drawable.selecteditem_dot)); // drawableDot2 = new ObservableField<>(context.getResources().getDrawable(R.drawable.nonselecteditem_dot)); // drawableDot3 = new ObservableField<>(context.getResources().getDrawable(R.drawable.nonselecteditem_dot)); // } // // // // } // Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/EncryptFragment.java import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.tresorit.zerokitsdk.ZerokitApplication; import com.tresorit.zerokitsdk.component.DaggerEncryptComponent; import com.tresorit.zerokitsdk.databinding.FragmentEncryptBinding; import com.tresorit.zerokitsdk.message.CreateTresorFinishedMessage; import com.tresorit.zerokitsdk.module.EncryptModule; import com.tresorit.zerokitsdk.viewmodel.EncryptViewModel; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import javax.inject.Inject; @Inject EventBus eventBus; @SuppressWarnings("WeakerAccess") FragmentEncryptBinding binding; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { binding = FragmentEncryptBinding.inflate(inflater, container, false); DaggerEncryptComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).encryptModule(new EncryptModule(getChildFragmentManager())).build().inject(this); binding.setViewmodel(viewModel); binding.pager.setPagingEnabled(false); return binding.getRoot(); } @Override public void onStart() { super.onStart(); eventBus.register(this); } @Override public void onStop() { super.onStop(); eventBus.unregister(this); } @Subscribe @SuppressWarnings("unused")
public void onEvent(@SuppressWarnings("UnusedParameters") CreateTresorFinishedMessage message){
tresorit/ZeroKit-Android-SDK
sample/src/main/java/com/tresorit/zerokitsdk/component/SignInComponent.java
// Path: sample/src/main/java/com/tresorit/zerokitsdk/activity/SignInActivity.java // public class SignInActivity extends ComponentControllerActivity<SignInComponent> { // // private static final int REQ_DEFAULT = 0; // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // SignInViewModel viewModel; // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // EventBus eventBus; // // @SuppressWarnings("WeakerAccess") // ActivitySigninBinding binding; // // @Override // public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // getComponent().inject(this); // binding = DataBindingUtil.setContentView(this, R.layout.activity_signin); // binding.setViewmodel(viewModel); // binding.container.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { // @Override // public void onGlobalLayout() { // binding.bottomBar.post(new Runnable() { // @Override // public void run() { // binding.bottomBar.setVisibility(binding.container.getRootView().getHeight() - binding.container.getHeight() > dpToPx(SignInActivity.this, 200) ? View.GONE : View.VISIBLE); // } // }); // } // }); // } // // @Override // protected SignInComponent onCreateNonConfigurationComponent() { // return DaggerSignInComponent.builder().applicationComponent(ZerokitApplication.get(this).component()).build(); // } // // @Override // protected void onActivityResult(int requestCode, int resultCode, Intent data) { // super.onActivityResult(requestCode, resultCode, data); // switch (requestCode) { // case REQ_DEFAULT: // finish(); // break; // } // } // // @Override // protected void onStart() { // super.onStart(); // eventBus.register(this); // } // // @Override // protected void onStop() { // eventBus.unregister(this); // super.onStop(); // } // // // @Subscribe // @SuppressWarnings("unused") // public void onEvent(ShowMessageMessage message) { // showMessage(message.getMessage()); // } // // @Subscribe // @SuppressWarnings("unused") // public void onEvent(@SuppressWarnings("UnusedParameters") LoginFinisedMessage message) { // startActivityForResult(new Intent(this, MainActivity.class), REQ_DEFAULT); // } // // private void showMessage(String message) { // Snackbar.make(binding.container, message, Snackbar.LENGTH_LONG).show(); // } // // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/SignInModule.java // @Module // public class SignInModule { // @Provides // @ActivityScope // public SignInViewModel provideSignInViewModel(EventBus eventBus) { // return new SignInViewModel(eventBus); // } // }
import com.tresorit.zerokitsdk.activity.SignInActivity; import com.tresorit.zerokitsdk.module.SignInModule; import com.tresorit.zerokitsdk.scopes.ActivityScope; import dagger.Component;
package com.tresorit.zerokitsdk.component; @ActivityScope @Component( modules = {
// Path: sample/src/main/java/com/tresorit/zerokitsdk/activity/SignInActivity.java // public class SignInActivity extends ComponentControllerActivity<SignInComponent> { // // private static final int REQ_DEFAULT = 0; // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // SignInViewModel viewModel; // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // EventBus eventBus; // // @SuppressWarnings("WeakerAccess") // ActivitySigninBinding binding; // // @Override // public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // getComponent().inject(this); // binding = DataBindingUtil.setContentView(this, R.layout.activity_signin); // binding.setViewmodel(viewModel); // binding.container.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { // @Override // public void onGlobalLayout() { // binding.bottomBar.post(new Runnable() { // @Override // public void run() { // binding.bottomBar.setVisibility(binding.container.getRootView().getHeight() - binding.container.getHeight() > dpToPx(SignInActivity.this, 200) ? View.GONE : View.VISIBLE); // } // }); // } // }); // } // // @Override // protected SignInComponent onCreateNonConfigurationComponent() { // return DaggerSignInComponent.builder().applicationComponent(ZerokitApplication.get(this).component()).build(); // } // // @Override // protected void onActivityResult(int requestCode, int resultCode, Intent data) { // super.onActivityResult(requestCode, resultCode, data); // switch (requestCode) { // case REQ_DEFAULT: // finish(); // break; // } // } // // @Override // protected void onStart() { // super.onStart(); // eventBus.register(this); // } // // @Override // protected void onStop() { // eventBus.unregister(this); // super.onStop(); // } // // // @Subscribe // @SuppressWarnings("unused") // public void onEvent(ShowMessageMessage message) { // showMessage(message.getMessage()); // } // // @Subscribe // @SuppressWarnings("unused") // public void onEvent(@SuppressWarnings("UnusedParameters") LoginFinisedMessage message) { // startActivityForResult(new Intent(this, MainActivity.class), REQ_DEFAULT); // } // // private void showMessage(String message) { // Snackbar.make(binding.container, message, Snackbar.LENGTH_LONG).show(); // } // // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/SignInModule.java // @Module // public class SignInModule { // @Provides // @ActivityScope // public SignInViewModel provideSignInViewModel(EventBus eventBus) { // return new SignInViewModel(eventBus); // } // } // Path: sample/src/main/java/com/tresorit/zerokitsdk/component/SignInComponent.java import com.tresorit.zerokitsdk.activity.SignInActivity; import com.tresorit.zerokitsdk.module.SignInModule; import com.tresorit.zerokitsdk.scopes.ActivityScope; import dagger.Component; package com.tresorit.zerokitsdk.component; @ActivityScope @Component( modules = {
SignInModule.class
tresorit/ZeroKit-Android-SDK
sample/src/main/java/com/tresorit/zerokitsdk/component/SignInComponent.java
// Path: sample/src/main/java/com/tresorit/zerokitsdk/activity/SignInActivity.java // public class SignInActivity extends ComponentControllerActivity<SignInComponent> { // // private static final int REQ_DEFAULT = 0; // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // SignInViewModel viewModel; // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // EventBus eventBus; // // @SuppressWarnings("WeakerAccess") // ActivitySigninBinding binding; // // @Override // public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // getComponent().inject(this); // binding = DataBindingUtil.setContentView(this, R.layout.activity_signin); // binding.setViewmodel(viewModel); // binding.container.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { // @Override // public void onGlobalLayout() { // binding.bottomBar.post(new Runnable() { // @Override // public void run() { // binding.bottomBar.setVisibility(binding.container.getRootView().getHeight() - binding.container.getHeight() > dpToPx(SignInActivity.this, 200) ? View.GONE : View.VISIBLE); // } // }); // } // }); // } // // @Override // protected SignInComponent onCreateNonConfigurationComponent() { // return DaggerSignInComponent.builder().applicationComponent(ZerokitApplication.get(this).component()).build(); // } // // @Override // protected void onActivityResult(int requestCode, int resultCode, Intent data) { // super.onActivityResult(requestCode, resultCode, data); // switch (requestCode) { // case REQ_DEFAULT: // finish(); // break; // } // } // // @Override // protected void onStart() { // super.onStart(); // eventBus.register(this); // } // // @Override // protected void onStop() { // eventBus.unregister(this); // super.onStop(); // } // // // @Subscribe // @SuppressWarnings("unused") // public void onEvent(ShowMessageMessage message) { // showMessage(message.getMessage()); // } // // @Subscribe // @SuppressWarnings("unused") // public void onEvent(@SuppressWarnings("UnusedParameters") LoginFinisedMessage message) { // startActivityForResult(new Intent(this, MainActivity.class), REQ_DEFAULT); // } // // private void showMessage(String message) { // Snackbar.make(binding.container, message, Snackbar.LENGTH_LONG).show(); // } // // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/SignInModule.java // @Module // public class SignInModule { // @Provides // @ActivityScope // public SignInViewModel provideSignInViewModel(EventBus eventBus) { // return new SignInViewModel(eventBus); // } // }
import com.tresorit.zerokitsdk.activity.SignInActivity; import com.tresorit.zerokitsdk.module.SignInModule; import com.tresorit.zerokitsdk.scopes.ActivityScope; import dagger.Component;
package com.tresorit.zerokitsdk.component; @ActivityScope @Component( modules = { SignInModule.class }, dependencies = { ApplicationComponent.class } ) public interface SignInComponent {
// Path: sample/src/main/java/com/tresorit/zerokitsdk/activity/SignInActivity.java // public class SignInActivity extends ComponentControllerActivity<SignInComponent> { // // private static final int REQ_DEFAULT = 0; // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // SignInViewModel viewModel; // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // EventBus eventBus; // // @SuppressWarnings("WeakerAccess") // ActivitySigninBinding binding; // // @Override // public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // getComponent().inject(this); // binding = DataBindingUtil.setContentView(this, R.layout.activity_signin); // binding.setViewmodel(viewModel); // binding.container.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { // @Override // public void onGlobalLayout() { // binding.bottomBar.post(new Runnable() { // @Override // public void run() { // binding.bottomBar.setVisibility(binding.container.getRootView().getHeight() - binding.container.getHeight() > dpToPx(SignInActivity.this, 200) ? View.GONE : View.VISIBLE); // } // }); // } // }); // } // // @Override // protected SignInComponent onCreateNonConfigurationComponent() { // return DaggerSignInComponent.builder().applicationComponent(ZerokitApplication.get(this).component()).build(); // } // // @Override // protected void onActivityResult(int requestCode, int resultCode, Intent data) { // super.onActivityResult(requestCode, resultCode, data); // switch (requestCode) { // case REQ_DEFAULT: // finish(); // break; // } // } // // @Override // protected void onStart() { // super.onStart(); // eventBus.register(this); // } // // @Override // protected void onStop() { // eventBus.unregister(this); // super.onStop(); // } // // // @Subscribe // @SuppressWarnings("unused") // public void onEvent(ShowMessageMessage message) { // showMessage(message.getMessage()); // } // // @Subscribe // @SuppressWarnings("unused") // public void onEvent(@SuppressWarnings("UnusedParameters") LoginFinisedMessage message) { // startActivityForResult(new Intent(this, MainActivity.class), REQ_DEFAULT); // } // // private void showMessage(String message) { // Snackbar.make(binding.container, message, Snackbar.LENGTH_LONG).show(); // } // // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/SignInModule.java // @Module // public class SignInModule { // @Provides // @ActivityScope // public SignInViewModel provideSignInViewModel(EventBus eventBus) { // return new SignInViewModel(eventBus); // } // } // Path: sample/src/main/java/com/tresorit/zerokitsdk/component/SignInComponent.java import com.tresorit.zerokitsdk.activity.SignInActivity; import com.tresorit.zerokitsdk.module.SignInModule; import com.tresorit.zerokitsdk.scopes.ActivityScope; import dagger.Component; package com.tresorit.zerokitsdk.component; @ActivityScope @Component( modules = { SignInModule.class }, dependencies = { ApplicationComponent.class } ) public interface SignInComponent {
void inject(SignInActivity activity);
tresorit/ZeroKit-Android-SDK
zerokit/src/main/java/com/tresorit/zerokit/response/ResponseZerokitPasswordStrength.java
// Path: zerokit/src/main/java/com/tresorit/zerokit/util/JSONObject.java // public class JSONObject { // // private org.json.JSONObject jsonObject; // // public JSONObject() { // jsonObject = new org.json.JSONObject(); // } // // public JSONObject(String json) { // try { // jsonObject = new org.json.JSONObject(json); // } catch (JSONException e) { // //e.printStackTrace(); // jsonObject = new org.json.JSONObject(); // } // } // // public org.json.JSONObject getJSONObject(String name) { // if (jsonObject != null) // try { // return jsonObject.getJSONObject(name); // } catch (JSONException e) { // //e.printStackTrace(); // } // return new org.json.JSONObject(); // } // // // public String getString(String name) { // if (jsonObject != null) // try { // return jsonObject.getString(name); // } catch (JSONException e) { // //e.printStackTrace(); // } // return ""; // } // // public double getDouble(String name) { // if (jsonObject != null) // try { // return jsonObject.getDouble(name); // } catch (JSONException e) { // //e.printStackTrace(); // } // return 0; // } // // public int getInt(String name) { // if (jsonObject != null) // try { // return jsonObject.getInt(name); // } catch (JSONException e) { // //e.printStackTrace(); // } // return 0; // } // // public List<String> getStringArray(String name) { // if (jsonObject != null) // try { // JSONArray jsonArray = jsonObject.getJSONArray(name); // List<String> result = new ArrayList<>(); // for (int i = 0; i < jsonArray.length(); i++) // result.add(jsonArray.getString(i)); // return result; // } catch (JSONException e) { // //e.printStackTrace(); // } // return new ArrayList<>(); // } // // public JSONObject put(String name, Object value) { // if (jsonObject != null) // try { // jsonObject.put(name, value); // } catch (JSONException e) { // //e.printStackTrace(); // } // return this; // } // // @Override // public String toString() { // return jsonObject != null ? jsonObject.toString() : ""; // } // } // // Path: common/src/main/java/com/tresorit/zerokit/util/ZerokitJson.java // public abstract class ZerokitJson { // // public abstract <T extends ZerokitJson> T parse(String json); // // }
import com.tresorit.zerokit.util.JSONObject; import com.tresorit.zerokit.util.ZerokitJson;
package com.tresorit.zerokit.response; public class ResponseZerokitPasswordStrength extends ZerokitJson { private CrackTimesSeconds crack_times_seconds; private Feedback feedback; private double guesses_log10; private int length; private int score; public CrackTimesSeconds getCrack_times_seconds() { return crack_times_seconds; } public double getGuesses_log10() { return guesses_log10; } public Feedback getFeedback() { return feedback; } public int getLength() { return length; } public int getScore() { return score; } @Override public String toString() { return String.format("crack_times_seconds: %s, feedback: %s, guesses_log10: %s, length: %s, score: %s", crack_times_seconds, feedback, guesses_log10, length, score); } @SuppressWarnings("unchecked") @Override public <T extends ZerokitJson> T parse(String json) {
// Path: zerokit/src/main/java/com/tresorit/zerokit/util/JSONObject.java // public class JSONObject { // // private org.json.JSONObject jsonObject; // // public JSONObject() { // jsonObject = new org.json.JSONObject(); // } // // public JSONObject(String json) { // try { // jsonObject = new org.json.JSONObject(json); // } catch (JSONException e) { // //e.printStackTrace(); // jsonObject = new org.json.JSONObject(); // } // } // // public org.json.JSONObject getJSONObject(String name) { // if (jsonObject != null) // try { // return jsonObject.getJSONObject(name); // } catch (JSONException e) { // //e.printStackTrace(); // } // return new org.json.JSONObject(); // } // // // public String getString(String name) { // if (jsonObject != null) // try { // return jsonObject.getString(name); // } catch (JSONException e) { // //e.printStackTrace(); // } // return ""; // } // // public double getDouble(String name) { // if (jsonObject != null) // try { // return jsonObject.getDouble(name); // } catch (JSONException e) { // //e.printStackTrace(); // } // return 0; // } // // public int getInt(String name) { // if (jsonObject != null) // try { // return jsonObject.getInt(name); // } catch (JSONException e) { // //e.printStackTrace(); // } // return 0; // } // // public List<String> getStringArray(String name) { // if (jsonObject != null) // try { // JSONArray jsonArray = jsonObject.getJSONArray(name); // List<String> result = new ArrayList<>(); // for (int i = 0; i < jsonArray.length(); i++) // result.add(jsonArray.getString(i)); // return result; // } catch (JSONException e) { // //e.printStackTrace(); // } // return new ArrayList<>(); // } // // public JSONObject put(String name, Object value) { // if (jsonObject != null) // try { // jsonObject.put(name, value); // } catch (JSONException e) { // //e.printStackTrace(); // } // return this; // } // // @Override // public String toString() { // return jsonObject != null ? jsonObject.toString() : ""; // } // } // // Path: common/src/main/java/com/tresorit/zerokit/util/ZerokitJson.java // public abstract class ZerokitJson { // // public abstract <T extends ZerokitJson> T parse(String json); // // } // Path: zerokit/src/main/java/com/tresorit/zerokit/response/ResponseZerokitPasswordStrength.java import com.tresorit.zerokit.util.JSONObject; import com.tresorit.zerokit.util.ZerokitJson; package com.tresorit.zerokit.response; public class ResponseZerokitPasswordStrength extends ZerokitJson { private CrackTimesSeconds crack_times_seconds; private Feedback feedback; private double guesses_log10; private int length; private int score; public CrackTimesSeconds getCrack_times_seconds() { return crack_times_seconds; } public double getGuesses_log10() { return guesses_log10; } public Feedback getFeedback() { return feedback; } public int getLength() { return length; } public int getScore() { return score; } @Override public String toString() { return String.format("crack_times_seconds: %s, feedback: %s, guesses_log10: %s, length: %s, score: %s", crack_times_seconds, feedback, guesses_log10, length, score); } @SuppressWarnings("unchecked") @Override public <T extends ZerokitJson> T parse(String json) {
JSONObject jsonObject = new JSONObject(json);
tresorit/ZeroKit-Android-SDK
sample/src/main/java/com/tresorit/zerokitsdk/component/DecryptComponent.java
// Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/DecryptFragment.java // public class DecryptFragment extends Fragment { // // @SuppressWarnings("WeakerAccess") // @Inject // DecryptViewModel viewModel; // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // DaggerDecryptComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentDecryptBinding binding = FragmentDecryptBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/DecryptModule.java // @Module // public class DecryptModule { // @Provides // @ActivityScope // public DecryptViewModel provideEncryptTextViewModel(Zerokit zerokit) { // return new DecryptViewModel(zerokit); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/viewmodel/DecryptViewModel.java // public class DecryptViewModel extends BaseObservable { // // @SuppressWarnings("WeakerAccess") // public final View.OnClickListener clickListenerDecrypt; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Boolean> inProgressDecrypt; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> textEncrypted; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> textDecrypted; // // private final Zerokit zerokit; // // @Inject // public DecryptViewModel(Zerokit zerokit) { // this.zerokit = zerokit; // // this.inProgressDecrypt = new ObservableField<>(false); // this.textEncrypted = new ObservableField<>(); // this.textDecrypted = new ObservableField<>(); // this.clickListenerDecrypt = new View.OnClickListener() { // @Override // public void onClick(View v) { // decrypt(textEncrypted.get()); // } // }; // } // // // @SuppressWarnings("WeakerAccess") // void decrypt(String cipherText){ // inProgressDecrypt.set(true); // zerokit.decrypt(cipherText).enqueue(new Action<String>() { // @Override // public void call(String decryptedText) { // inProgressDecrypt.set(false); // textDecrypted.set(decryptedText); // } // }, new Action<ResponseZerokitError>() { // @Override // public void call(ResponseZerokitError responseError) { // inProgressDecrypt.set(false); // textDecrypted.set(""); // } // }); // } // // }
import com.tresorit.zerokitsdk.fragment.DecryptFragment; import com.tresorit.zerokitsdk.module.DecryptModule; import com.tresorit.zerokitsdk.scopes.ActivityScope; import com.tresorit.zerokitsdk.viewmodel.DecryptViewModel; import dagger.Component;
package com.tresorit.zerokitsdk.component; @ActivityScope @Component( modules = {
// Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/DecryptFragment.java // public class DecryptFragment extends Fragment { // // @SuppressWarnings("WeakerAccess") // @Inject // DecryptViewModel viewModel; // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // DaggerDecryptComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentDecryptBinding binding = FragmentDecryptBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/DecryptModule.java // @Module // public class DecryptModule { // @Provides // @ActivityScope // public DecryptViewModel provideEncryptTextViewModel(Zerokit zerokit) { // return new DecryptViewModel(zerokit); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/viewmodel/DecryptViewModel.java // public class DecryptViewModel extends BaseObservable { // // @SuppressWarnings("WeakerAccess") // public final View.OnClickListener clickListenerDecrypt; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Boolean> inProgressDecrypt; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> textEncrypted; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> textDecrypted; // // private final Zerokit zerokit; // // @Inject // public DecryptViewModel(Zerokit zerokit) { // this.zerokit = zerokit; // // this.inProgressDecrypt = new ObservableField<>(false); // this.textEncrypted = new ObservableField<>(); // this.textDecrypted = new ObservableField<>(); // this.clickListenerDecrypt = new View.OnClickListener() { // @Override // public void onClick(View v) { // decrypt(textEncrypted.get()); // } // }; // } // // // @SuppressWarnings("WeakerAccess") // void decrypt(String cipherText){ // inProgressDecrypt.set(true); // zerokit.decrypt(cipherText).enqueue(new Action<String>() { // @Override // public void call(String decryptedText) { // inProgressDecrypt.set(false); // textDecrypted.set(decryptedText); // } // }, new Action<ResponseZerokitError>() { // @Override // public void call(ResponseZerokitError responseError) { // inProgressDecrypt.set(false); // textDecrypted.set(""); // } // }); // } // // } // Path: sample/src/main/java/com/tresorit/zerokitsdk/component/DecryptComponent.java import com.tresorit.zerokitsdk.fragment.DecryptFragment; import com.tresorit.zerokitsdk.module.DecryptModule; import com.tresorit.zerokitsdk.scopes.ActivityScope; import com.tresorit.zerokitsdk.viewmodel.DecryptViewModel; import dagger.Component; package com.tresorit.zerokitsdk.component; @ActivityScope @Component( modules = {
DecryptModule.class
tresorit/ZeroKit-Android-SDK
sample/src/main/java/com/tresorit/zerokitsdk/component/DecryptComponent.java
// Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/DecryptFragment.java // public class DecryptFragment extends Fragment { // // @SuppressWarnings("WeakerAccess") // @Inject // DecryptViewModel viewModel; // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // DaggerDecryptComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentDecryptBinding binding = FragmentDecryptBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/DecryptModule.java // @Module // public class DecryptModule { // @Provides // @ActivityScope // public DecryptViewModel provideEncryptTextViewModel(Zerokit zerokit) { // return new DecryptViewModel(zerokit); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/viewmodel/DecryptViewModel.java // public class DecryptViewModel extends BaseObservable { // // @SuppressWarnings("WeakerAccess") // public final View.OnClickListener clickListenerDecrypt; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Boolean> inProgressDecrypt; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> textEncrypted; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> textDecrypted; // // private final Zerokit zerokit; // // @Inject // public DecryptViewModel(Zerokit zerokit) { // this.zerokit = zerokit; // // this.inProgressDecrypt = new ObservableField<>(false); // this.textEncrypted = new ObservableField<>(); // this.textDecrypted = new ObservableField<>(); // this.clickListenerDecrypt = new View.OnClickListener() { // @Override // public void onClick(View v) { // decrypt(textEncrypted.get()); // } // }; // } // // // @SuppressWarnings("WeakerAccess") // void decrypt(String cipherText){ // inProgressDecrypt.set(true); // zerokit.decrypt(cipherText).enqueue(new Action<String>() { // @Override // public void call(String decryptedText) { // inProgressDecrypt.set(false); // textDecrypted.set(decryptedText); // } // }, new Action<ResponseZerokitError>() { // @Override // public void call(ResponseZerokitError responseError) { // inProgressDecrypt.set(false); // textDecrypted.set(""); // } // }); // } // // }
import com.tresorit.zerokitsdk.fragment.DecryptFragment; import com.tresorit.zerokitsdk.module.DecryptModule; import com.tresorit.zerokitsdk.scopes.ActivityScope; import com.tresorit.zerokitsdk.viewmodel.DecryptViewModel; import dagger.Component;
package com.tresorit.zerokitsdk.component; @ActivityScope @Component( modules = { DecryptModule.class }, dependencies = { ApplicationComponent.class } ) public interface DecryptComponent {
// Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/DecryptFragment.java // public class DecryptFragment extends Fragment { // // @SuppressWarnings("WeakerAccess") // @Inject // DecryptViewModel viewModel; // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // DaggerDecryptComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentDecryptBinding binding = FragmentDecryptBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/DecryptModule.java // @Module // public class DecryptModule { // @Provides // @ActivityScope // public DecryptViewModel provideEncryptTextViewModel(Zerokit zerokit) { // return new DecryptViewModel(zerokit); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/viewmodel/DecryptViewModel.java // public class DecryptViewModel extends BaseObservable { // // @SuppressWarnings("WeakerAccess") // public final View.OnClickListener clickListenerDecrypt; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Boolean> inProgressDecrypt; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> textEncrypted; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> textDecrypted; // // private final Zerokit zerokit; // // @Inject // public DecryptViewModel(Zerokit zerokit) { // this.zerokit = zerokit; // // this.inProgressDecrypt = new ObservableField<>(false); // this.textEncrypted = new ObservableField<>(); // this.textDecrypted = new ObservableField<>(); // this.clickListenerDecrypt = new View.OnClickListener() { // @Override // public void onClick(View v) { // decrypt(textEncrypted.get()); // } // }; // } // // // @SuppressWarnings("WeakerAccess") // void decrypt(String cipherText){ // inProgressDecrypt.set(true); // zerokit.decrypt(cipherText).enqueue(new Action<String>() { // @Override // public void call(String decryptedText) { // inProgressDecrypt.set(false); // textDecrypted.set(decryptedText); // } // }, new Action<ResponseZerokitError>() { // @Override // public void call(ResponseZerokitError responseError) { // inProgressDecrypt.set(false); // textDecrypted.set(""); // } // }); // } // // } // Path: sample/src/main/java/com/tresorit/zerokitsdk/component/DecryptComponent.java import com.tresorit.zerokitsdk.fragment.DecryptFragment; import com.tresorit.zerokitsdk.module.DecryptModule; import com.tresorit.zerokitsdk.scopes.ActivityScope; import com.tresorit.zerokitsdk.viewmodel.DecryptViewModel; import dagger.Component; package com.tresorit.zerokitsdk.component; @ActivityScope @Component( modules = { DecryptModule.class }, dependencies = { ApplicationComponent.class } ) public interface DecryptComponent {
void inject(DecryptFragment fragment);
tresorit/ZeroKit-Android-SDK
sample/src/main/java/com/tresorit/zerokitsdk/component/DecryptComponent.java
// Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/DecryptFragment.java // public class DecryptFragment extends Fragment { // // @SuppressWarnings("WeakerAccess") // @Inject // DecryptViewModel viewModel; // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // DaggerDecryptComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentDecryptBinding binding = FragmentDecryptBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/DecryptModule.java // @Module // public class DecryptModule { // @Provides // @ActivityScope // public DecryptViewModel provideEncryptTextViewModel(Zerokit zerokit) { // return new DecryptViewModel(zerokit); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/viewmodel/DecryptViewModel.java // public class DecryptViewModel extends BaseObservable { // // @SuppressWarnings("WeakerAccess") // public final View.OnClickListener clickListenerDecrypt; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Boolean> inProgressDecrypt; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> textEncrypted; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> textDecrypted; // // private final Zerokit zerokit; // // @Inject // public DecryptViewModel(Zerokit zerokit) { // this.zerokit = zerokit; // // this.inProgressDecrypt = new ObservableField<>(false); // this.textEncrypted = new ObservableField<>(); // this.textDecrypted = new ObservableField<>(); // this.clickListenerDecrypt = new View.OnClickListener() { // @Override // public void onClick(View v) { // decrypt(textEncrypted.get()); // } // }; // } // // // @SuppressWarnings("WeakerAccess") // void decrypt(String cipherText){ // inProgressDecrypt.set(true); // zerokit.decrypt(cipherText).enqueue(new Action<String>() { // @Override // public void call(String decryptedText) { // inProgressDecrypt.set(false); // textDecrypted.set(decryptedText); // } // }, new Action<ResponseZerokitError>() { // @Override // public void call(ResponseZerokitError responseError) { // inProgressDecrypt.set(false); // textDecrypted.set(""); // } // }); // } // // }
import com.tresorit.zerokitsdk.fragment.DecryptFragment; import com.tresorit.zerokitsdk.module.DecryptModule; import com.tresorit.zerokitsdk.scopes.ActivityScope; import com.tresorit.zerokitsdk.viewmodel.DecryptViewModel; import dagger.Component;
package com.tresorit.zerokitsdk.component; @ActivityScope @Component( modules = { DecryptModule.class }, dependencies = { ApplicationComponent.class } ) public interface DecryptComponent { void inject(DecryptFragment fragment);
// Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/DecryptFragment.java // public class DecryptFragment extends Fragment { // // @SuppressWarnings("WeakerAccess") // @Inject // DecryptViewModel viewModel; // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // DaggerDecryptComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentDecryptBinding binding = FragmentDecryptBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/DecryptModule.java // @Module // public class DecryptModule { // @Provides // @ActivityScope // public DecryptViewModel provideEncryptTextViewModel(Zerokit zerokit) { // return new DecryptViewModel(zerokit); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/viewmodel/DecryptViewModel.java // public class DecryptViewModel extends BaseObservable { // // @SuppressWarnings("WeakerAccess") // public final View.OnClickListener clickListenerDecrypt; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Boolean> inProgressDecrypt; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> textEncrypted; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> textDecrypted; // // private final Zerokit zerokit; // // @Inject // public DecryptViewModel(Zerokit zerokit) { // this.zerokit = zerokit; // // this.inProgressDecrypt = new ObservableField<>(false); // this.textEncrypted = new ObservableField<>(); // this.textDecrypted = new ObservableField<>(); // this.clickListenerDecrypt = new View.OnClickListener() { // @Override // public void onClick(View v) { // decrypt(textEncrypted.get()); // } // }; // } // // // @SuppressWarnings("WeakerAccess") // void decrypt(String cipherText){ // inProgressDecrypt.set(true); // zerokit.decrypt(cipherText).enqueue(new Action<String>() { // @Override // public void call(String decryptedText) { // inProgressDecrypt.set(false); // textDecrypted.set(decryptedText); // } // }, new Action<ResponseZerokitError>() { // @Override // public void call(ResponseZerokitError responseError) { // inProgressDecrypt.set(false); // textDecrypted.set(""); // } // }); // } // // } // Path: sample/src/main/java/com/tresorit/zerokitsdk/component/DecryptComponent.java import com.tresorit.zerokitsdk.fragment.DecryptFragment; import com.tresorit.zerokitsdk.module.DecryptModule; import com.tresorit.zerokitsdk.scopes.ActivityScope; import com.tresorit.zerokitsdk.viewmodel.DecryptViewModel; import dagger.Component; package com.tresorit.zerokitsdk.component; @ActivityScope @Component( modules = { DecryptModule.class }, dependencies = { ApplicationComponent.class } ) public interface DecryptComponent { void inject(DecryptFragment fragment);
DecryptViewModel viewmodel();
tresorit/ZeroKit-Android-SDK
sample/src/main/java/com/tresorit/zerokitsdk/viewmodel/MainViewModel.java
// Path: sample/src/main/java/com/tresorit/zerokitsdk/message/TabSelectMessage.java // public class TabSelectMessage { // private final int tabId; // // public TabSelectMessage(int tabId) { // this.tabId = tabId; // } // // public int getTabId() { // return tabId; // } // }
import android.databinding.BaseObservable; import android.support.annotation.NonNull; import android.support.design.widget.BottomNavigationView; import android.view.MenuItem; import com.tresorit.zerokitsdk.message.TabSelectMessage; import org.greenrobot.eventbus.EventBus; import javax.inject.Inject;
package com.tresorit.zerokitsdk.viewmodel; public class MainViewModel extends BaseObservable { @SuppressWarnings("WeakerAccess") public final BottomNavigationView.OnNavigationItemSelectedListener onNavigationItemSelectedListener; @Inject public MainViewModel(final EventBus eventBus) { onNavigationItemSelectedListener = new BottomNavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) {
// Path: sample/src/main/java/com/tresorit/zerokitsdk/message/TabSelectMessage.java // public class TabSelectMessage { // private final int tabId; // // public TabSelectMessage(int tabId) { // this.tabId = tabId; // } // // public int getTabId() { // return tabId; // } // } // Path: sample/src/main/java/com/tresorit/zerokitsdk/viewmodel/MainViewModel.java import android.databinding.BaseObservable; import android.support.annotation.NonNull; import android.support.design.widget.BottomNavigationView; import android.view.MenuItem; import com.tresorit.zerokitsdk.message.TabSelectMessage; import org.greenrobot.eventbus.EventBus; import javax.inject.Inject; package com.tresorit.zerokitsdk.viewmodel; public class MainViewModel extends BaseObservable { @SuppressWarnings("WeakerAccess") public final BottomNavigationView.OnNavigationItemSelectedListener onNavigationItemSelectedListener; @Inject public MainViewModel(final EventBus eventBus) { onNavigationItemSelectedListener = new BottomNavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) {
eventBus.post(new TabSelectMessage(item.getItemId()));
tresorit/ZeroKit-Android-SDK
sample/src/main/java/com/tresorit/zerokitsdk/component/CreateTresorComponent.java
// Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/CreateTresorFragment.java // public class CreateTresorFragment extends Fragment { // // @SuppressWarnings("WeakerAccess") // @Inject // CreateTresorViewModel viewModel; // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // DaggerCreateTresorComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentCreateTresorBinding binding = FragmentCreateTresorBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/CreateTresorModule.java // @Module // public class CreateTresorModule { // @Provides // @ActivityScope // public CreateTresorViewModel provideCreateTresorViewModel(Zerokit zerokit, AdminApi adminApi, EventBus eventBus) { // return new CreateTresorViewModel(zerokit, adminApi, eventBus); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/viewmodel/CreateTresorViewModel.java // public class CreateTresorViewModel extends BaseObservable { // // @SuppressWarnings("WeakerAccess") // public final View.OnClickListener clickListener; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Boolean> inProgress; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> tresorId; // // private final Zerokit zerokit; // // @SuppressWarnings("WeakerAccess") // final AdminApi adminApi; // @SuppressWarnings("WeakerAccess") // final EventBus eventBus; // // @SuppressWarnings("WeakerAccess") // final Action<ResponseZerokitError> errorResponseHandlerSdk; // @SuppressWarnings("WeakerAccess") // final Action<ResponseAdminApiError> errorResponseHandlerAdminapi; // // // @Inject // public CreateTresorViewModel(final Zerokit zerokit, final AdminApi adminApi, final EventBus eventBus) { // this.zerokit = zerokit; // this.adminApi = adminApi; // this.eventBus = eventBus; // // // this.inProgress = new ObservableField<>(false); // this.tresorId = new ObservableField<>(""); // this.clickListener = new View.OnClickListener() { // @Override // public void onClick(View v) { // createTresor(); // inProgress.set(true); // } // }; // // errorResponseHandlerSdk = new Action<ResponseZerokitError>() { // @Override // public void call(ResponseZerokitError errorResponse) { // inProgress.set(false); // eventBus.post(new ShowMessageMessage(errorResponse.toString())); // } // }; // errorResponseHandlerAdminapi = new Action<ResponseAdminApiError>() { // @Override // public void call(ResponseAdminApiError errorResponse) { // inProgress.set(false); // eventBus.post(new ShowMessageMessage(errorResponse.toString())); // } // }; // } // // @SuppressWarnings("WeakerAccess") // void createTresor() { // inProgress.set(true); // this.zerokit.createTresor().enqueue(new Action<String>() { // @Override // public void call(final String tresorId) { // adminApi.createdTresor(tresorId).enqueue(new Action<Void>() { // @Override // public void call(Void res) { // CreateTresorViewModel.this.inProgress.set(false); // CreateTresorViewModel.this.tresorId.set("Tresor Id: " + tresorId); // CreateTresorViewModel.this.eventBus.post(new CreateTresorFinishedMessage(tresorId)); // } // }, errorResponseHandlerAdminapi); // } // }, errorResponseHandlerSdk); // } // }
import com.tresorit.zerokitsdk.fragment.CreateTresorFragment; import com.tresorit.zerokitsdk.module.CreateTresorModule; import com.tresorit.zerokitsdk.scopes.ActivityScope; import com.tresorit.zerokitsdk.viewmodel.CreateTresorViewModel; import dagger.Component;
package com.tresorit.zerokitsdk.component; @ActivityScope @Component( modules = {
// Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/CreateTresorFragment.java // public class CreateTresorFragment extends Fragment { // // @SuppressWarnings("WeakerAccess") // @Inject // CreateTresorViewModel viewModel; // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // DaggerCreateTresorComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentCreateTresorBinding binding = FragmentCreateTresorBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/CreateTresorModule.java // @Module // public class CreateTresorModule { // @Provides // @ActivityScope // public CreateTresorViewModel provideCreateTresorViewModel(Zerokit zerokit, AdminApi adminApi, EventBus eventBus) { // return new CreateTresorViewModel(zerokit, adminApi, eventBus); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/viewmodel/CreateTresorViewModel.java // public class CreateTresorViewModel extends BaseObservable { // // @SuppressWarnings("WeakerAccess") // public final View.OnClickListener clickListener; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Boolean> inProgress; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> tresorId; // // private final Zerokit zerokit; // // @SuppressWarnings("WeakerAccess") // final AdminApi adminApi; // @SuppressWarnings("WeakerAccess") // final EventBus eventBus; // // @SuppressWarnings("WeakerAccess") // final Action<ResponseZerokitError> errorResponseHandlerSdk; // @SuppressWarnings("WeakerAccess") // final Action<ResponseAdminApiError> errorResponseHandlerAdminapi; // // // @Inject // public CreateTresorViewModel(final Zerokit zerokit, final AdminApi adminApi, final EventBus eventBus) { // this.zerokit = zerokit; // this.adminApi = adminApi; // this.eventBus = eventBus; // // // this.inProgress = new ObservableField<>(false); // this.tresorId = new ObservableField<>(""); // this.clickListener = new View.OnClickListener() { // @Override // public void onClick(View v) { // createTresor(); // inProgress.set(true); // } // }; // // errorResponseHandlerSdk = new Action<ResponseZerokitError>() { // @Override // public void call(ResponseZerokitError errorResponse) { // inProgress.set(false); // eventBus.post(new ShowMessageMessage(errorResponse.toString())); // } // }; // errorResponseHandlerAdminapi = new Action<ResponseAdminApiError>() { // @Override // public void call(ResponseAdminApiError errorResponse) { // inProgress.set(false); // eventBus.post(new ShowMessageMessage(errorResponse.toString())); // } // }; // } // // @SuppressWarnings("WeakerAccess") // void createTresor() { // inProgress.set(true); // this.zerokit.createTresor().enqueue(new Action<String>() { // @Override // public void call(final String tresorId) { // adminApi.createdTresor(tresorId).enqueue(new Action<Void>() { // @Override // public void call(Void res) { // CreateTresorViewModel.this.inProgress.set(false); // CreateTresorViewModel.this.tresorId.set("Tresor Id: " + tresorId); // CreateTresorViewModel.this.eventBus.post(new CreateTresorFinishedMessage(tresorId)); // } // }, errorResponseHandlerAdminapi); // } // }, errorResponseHandlerSdk); // } // } // Path: sample/src/main/java/com/tresorit/zerokitsdk/component/CreateTresorComponent.java import com.tresorit.zerokitsdk.fragment.CreateTresorFragment; import com.tresorit.zerokitsdk.module.CreateTresorModule; import com.tresorit.zerokitsdk.scopes.ActivityScope; import com.tresorit.zerokitsdk.viewmodel.CreateTresorViewModel; import dagger.Component; package com.tresorit.zerokitsdk.component; @ActivityScope @Component( modules = {
CreateTresorModule.class
tresorit/ZeroKit-Android-SDK
sample/src/main/java/com/tresorit/zerokitsdk/component/CreateTresorComponent.java
// Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/CreateTresorFragment.java // public class CreateTresorFragment extends Fragment { // // @SuppressWarnings("WeakerAccess") // @Inject // CreateTresorViewModel viewModel; // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // DaggerCreateTresorComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentCreateTresorBinding binding = FragmentCreateTresorBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/CreateTresorModule.java // @Module // public class CreateTresorModule { // @Provides // @ActivityScope // public CreateTresorViewModel provideCreateTresorViewModel(Zerokit zerokit, AdminApi adminApi, EventBus eventBus) { // return new CreateTresorViewModel(zerokit, adminApi, eventBus); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/viewmodel/CreateTresorViewModel.java // public class CreateTresorViewModel extends BaseObservable { // // @SuppressWarnings("WeakerAccess") // public final View.OnClickListener clickListener; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Boolean> inProgress; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> tresorId; // // private final Zerokit zerokit; // // @SuppressWarnings("WeakerAccess") // final AdminApi adminApi; // @SuppressWarnings("WeakerAccess") // final EventBus eventBus; // // @SuppressWarnings("WeakerAccess") // final Action<ResponseZerokitError> errorResponseHandlerSdk; // @SuppressWarnings("WeakerAccess") // final Action<ResponseAdminApiError> errorResponseHandlerAdminapi; // // // @Inject // public CreateTresorViewModel(final Zerokit zerokit, final AdminApi adminApi, final EventBus eventBus) { // this.zerokit = zerokit; // this.adminApi = adminApi; // this.eventBus = eventBus; // // // this.inProgress = new ObservableField<>(false); // this.tresorId = new ObservableField<>(""); // this.clickListener = new View.OnClickListener() { // @Override // public void onClick(View v) { // createTresor(); // inProgress.set(true); // } // }; // // errorResponseHandlerSdk = new Action<ResponseZerokitError>() { // @Override // public void call(ResponseZerokitError errorResponse) { // inProgress.set(false); // eventBus.post(new ShowMessageMessage(errorResponse.toString())); // } // }; // errorResponseHandlerAdminapi = new Action<ResponseAdminApiError>() { // @Override // public void call(ResponseAdminApiError errorResponse) { // inProgress.set(false); // eventBus.post(new ShowMessageMessage(errorResponse.toString())); // } // }; // } // // @SuppressWarnings("WeakerAccess") // void createTresor() { // inProgress.set(true); // this.zerokit.createTresor().enqueue(new Action<String>() { // @Override // public void call(final String tresorId) { // adminApi.createdTresor(tresorId).enqueue(new Action<Void>() { // @Override // public void call(Void res) { // CreateTresorViewModel.this.inProgress.set(false); // CreateTresorViewModel.this.tresorId.set("Tresor Id: " + tresorId); // CreateTresorViewModel.this.eventBus.post(new CreateTresorFinishedMessage(tresorId)); // } // }, errorResponseHandlerAdminapi); // } // }, errorResponseHandlerSdk); // } // }
import com.tresorit.zerokitsdk.fragment.CreateTresorFragment; import com.tresorit.zerokitsdk.module.CreateTresorModule; import com.tresorit.zerokitsdk.scopes.ActivityScope; import com.tresorit.zerokitsdk.viewmodel.CreateTresorViewModel; import dagger.Component;
package com.tresorit.zerokitsdk.component; @ActivityScope @Component( modules = { CreateTresorModule.class }, dependencies = { ApplicationComponent.class } ) public interface CreateTresorComponent {
// Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/CreateTresorFragment.java // public class CreateTresorFragment extends Fragment { // // @SuppressWarnings("WeakerAccess") // @Inject // CreateTresorViewModel viewModel; // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // DaggerCreateTresorComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentCreateTresorBinding binding = FragmentCreateTresorBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/CreateTresorModule.java // @Module // public class CreateTresorModule { // @Provides // @ActivityScope // public CreateTresorViewModel provideCreateTresorViewModel(Zerokit zerokit, AdminApi adminApi, EventBus eventBus) { // return new CreateTresorViewModel(zerokit, adminApi, eventBus); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/viewmodel/CreateTresorViewModel.java // public class CreateTresorViewModel extends BaseObservable { // // @SuppressWarnings("WeakerAccess") // public final View.OnClickListener clickListener; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Boolean> inProgress; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> tresorId; // // private final Zerokit zerokit; // // @SuppressWarnings("WeakerAccess") // final AdminApi adminApi; // @SuppressWarnings("WeakerAccess") // final EventBus eventBus; // // @SuppressWarnings("WeakerAccess") // final Action<ResponseZerokitError> errorResponseHandlerSdk; // @SuppressWarnings("WeakerAccess") // final Action<ResponseAdminApiError> errorResponseHandlerAdminapi; // // // @Inject // public CreateTresorViewModel(final Zerokit zerokit, final AdminApi adminApi, final EventBus eventBus) { // this.zerokit = zerokit; // this.adminApi = adminApi; // this.eventBus = eventBus; // // // this.inProgress = new ObservableField<>(false); // this.tresorId = new ObservableField<>(""); // this.clickListener = new View.OnClickListener() { // @Override // public void onClick(View v) { // createTresor(); // inProgress.set(true); // } // }; // // errorResponseHandlerSdk = new Action<ResponseZerokitError>() { // @Override // public void call(ResponseZerokitError errorResponse) { // inProgress.set(false); // eventBus.post(new ShowMessageMessage(errorResponse.toString())); // } // }; // errorResponseHandlerAdminapi = new Action<ResponseAdminApiError>() { // @Override // public void call(ResponseAdminApiError errorResponse) { // inProgress.set(false); // eventBus.post(new ShowMessageMessage(errorResponse.toString())); // } // }; // } // // @SuppressWarnings("WeakerAccess") // void createTresor() { // inProgress.set(true); // this.zerokit.createTresor().enqueue(new Action<String>() { // @Override // public void call(final String tresorId) { // adminApi.createdTresor(tresorId).enqueue(new Action<Void>() { // @Override // public void call(Void res) { // CreateTresorViewModel.this.inProgress.set(false); // CreateTresorViewModel.this.tresorId.set("Tresor Id: " + tresorId); // CreateTresorViewModel.this.eventBus.post(new CreateTresorFinishedMessage(tresorId)); // } // }, errorResponseHandlerAdminapi); // } // }, errorResponseHandlerSdk); // } // } // Path: sample/src/main/java/com/tresorit/zerokitsdk/component/CreateTresorComponent.java import com.tresorit.zerokitsdk.fragment.CreateTresorFragment; import com.tresorit.zerokitsdk.module.CreateTresorModule; import com.tresorit.zerokitsdk.scopes.ActivityScope; import com.tresorit.zerokitsdk.viewmodel.CreateTresorViewModel; import dagger.Component; package com.tresorit.zerokitsdk.component; @ActivityScope @Component( modules = { CreateTresorModule.class }, dependencies = { ApplicationComponent.class } ) public interface CreateTresorComponent {
void inject(CreateTresorFragment fragment);
tresorit/ZeroKit-Android-SDK
sample/src/main/java/com/tresorit/zerokitsdk/component/CreateTresorComponent.java
// Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/CreateTresorFragment.java // public class CreateTresorFragment extends Fragment { // // @SuppressWarnings("WeakerAccess") // @Inject // CreateTresorViewModel viewModel; // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // DaggerCreateTresorComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentCreateTresorBinding binding = FragmentCreateTresorBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/CreateTresorModule.java // @Module // public class CreateTresorModule { // @Provides // @ActivityScope // public CreateTresorViewModel provideCreateTresorViewModel(Zerokit zerokit, AdminApi adminApi, EventBus eventBus) { // return new CreateTresorViewModel(zerokit, adminApi, eventBus); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/viewmodel/CreateTresorViewModel.java // public class CreateTresorViewModel extends BaseObservable { // // @SuppressWarnings("WeakerAccess") // public final View.OnClickListener clickListener; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Boolean> inProgress; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> tresorId; // // private final Zerokit zerokit; // // @SuppressWarnings("WeakerAccess") // final AdminApi adminApi; // @SuppressWarnings("WeakerAccess") // final EventBus eventBus; // // @SuppressWarnings("WeakerAccess") // final Action<ResponseZerokitError> errorResponseHandlerSdk; // @SuppressWarnings("WeakerAccess") // final Action<ResponseAdminApiError> errorResponseHandlerAdminapi; // // // @Inject // public CreateTresorViewModel(final Zerokit zerokit, final AdminApi adminApi, final EventBus eventBus) { // this.zerokit = zerokit; // this.adminApi = adminApi; // this.eventBus = eventBus; // // // this.inProgress = new ObservableField<>(false); // this.tresorId = new ObservableField<>(""); // this.clickListener = new View.OnClickListener() { // @Override // public void onClick(View v) { // createTresor(); // inProgress.set(true); // } // }; // // errorResponseHandlerSdk = new Action<ResponseZerokitError>() { // @Override // public void call(ResponseZerokitError errorResponse) { // inProgress.set(false); // eventBus.post(new ShowMessageMessage(errorResponse.toString())); // } // }; // errorResponseHandlerAdminapi = new Action<ResponseAdminApiError>() { // @Override // public void call(ResponseAdminApiError errorResponse) { // inProgress.set(false); // eventBus.post(new ShowMessageMessage(errorResponse.toString())); // } // }; // } // // @SuppressWarnings("WeakerAccess") // void createTresor() { // inProgress.set(true); // this.zerokit.createTresor().enqueue(new Action<String>() { // @Override // public void call(final String tresorId) { // adminApi.createdTresor(tresorId).enqueue(new Action<Void>() { // @Override // public void call(Void res) { // CreateTresorViewModel.this.inProgress.set(false); // CreateTresorViewModel.this.tresorId.set("Tresor Id: " + tresorId); // CreateTresorViewModel.this.eventBus.post(new CreateTresorFinishedMessage(tresorId)); // } // }, errorResponseHandlerAdminapi); // } // }, errorResponseHandlerSdk); // } // }
import com.tresorit.zerokitsdk.fragment.CreateTresorFragment; import com.tresorit.zerokitsdk.module.CreateTresorModule; import com.tresorit.zerokitsdk.scopes.ActivityScope; import com.tresorit.zerokitsdk.viewmodel.CreateTresorViewModel; import dagger.Component;
package com.tresorit.zerokitsdk.component; @ActivityScope @Component( modules = { CreateTresorModule.class }, dependencies = { ApplicationComponent.class } ) public interface CreateTresorComponent { void inject(CreateTresorFragment fragment);
// Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/CreateTresorFragment.java // public class CreateTresorFragment extends Fragment { // // @SuppressWarnings("WeakerAccess") // @Inject // CreateTresorViewModel viewModel; // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // DaggerCreateTresorComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentCreateTresorBinding binding = FragmentCreateTresorBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/CreateTresorModule.java // @Module // public class CreateTresorModule { // @Provides // @ActivityScope // public CreateTresorViewModel provideCreateTresorViewModel(Zerokit zerokit, AdminApi adminApi, EventBus eventBus) { // return new CreateTresorViewModel(zerokit, adminApi, eventBus); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/viewmodel/CreateTresorViewModel.java // public class CreateTresorViewModel extends BaseObservable { // // @SuppressWarnings("WeakerAccess") // public final View.OnClickListener clickListener; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Boolean> inProgress; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> tresorId; // // private final Zerokit zerokit; // // @SuppressWarnings("WeakerAccess") // final AdminApi adminApi; // @SuppressWarnings("WeakerAccess") // final EventBus eventBus; // // @SuppressWarnings("WeakerAccess") // final Action<ResponseZerokitError> errorResponseHandlerSdk; // @SuppressWarnings("WeakerAccess") // final Action<ResponseAdminApiError> errorResponseHandlerAdminapi; // // // @Inject // public CreateTresorViewModel(final Zerokit zerokit, final AdminApi adminApi, final EventBus eventBus) { // this.zerokit = zerokit; // this.adminApi = adminApi; // this.eventBus = eventBus; // // // this.inProgress = new ObservableField<>(false); // this.tresorId = new ObservableField<>(""); // this.clickListener = new View.OnClickListener() { // @Override // public void onClick(View v) { // createTresor(); // inProgress.set(true); // } // }; // // errorResponseHandlerSdk = new Action<ResponseZerokitError>() { // @Override // public void call(ResponseZerokitError errorResponse) { // inProgress.set(false); // eventBus.post(new ShowMessageMessage(errorResponse.toString())); // } // }; // errorResponseHandlerAdminapi = new Action<ResponseAdminApiError>() { // @Override // public void call(ResponseAdminApiError errorResponse) { // inProgress.set(false); // eventBus.post(new ShowMessageMessage(errorResponse.toString())); // } // }; // } // // @SuppressWarnings("WeakerAccess") // void createTresor() { // inProgress.set(true); // this.zerokit.createTresor().enqueue(new Action<String>() { // @Override // public void call(final String tresorId) { // adminApi.createdTresor(tresorId).enqueue(new Action<Void>() { // @Override // public void call(Void res) { // CreateTresorViewModel.this.inProgress.set(false); // CreateTresorViewModel.this.tresorId.set("Tresor Id: " + tresorId); // CreateTresorViewModel.this.eventBus.post(new CreateTresorFinishedMessage(tresorId)); // } // }, errorResponseHandlerAdminapi); // } // }, errorResponseHandlerSdk); // } // } // Path: sample/src/main/java/com/tresorit/zerokitsdk/component/CreateTresorComponent.java import com.tresorit.zerokitsdk.fragment.CreateTresorFragment; import com.tresorit.zerokitsdk.module.CreateTresorModule; import com.tresorit.zerokitsdk.scopes.ActivityScope; import com.tresorit.zerokitsdk.viewmodel.CreateTresorViewModel; import dagger.Component; package com.tresorit.zerokitsdk.component; @ActivityScope @Component( modules = { CreateTresorModule.class }, dependencies = { ApplicationComponent.class } ) public interface CreateTresorComponent { void inject(CreateTresorFragment fragment);
CreateTresorViewModel viewmodel();
tresorit/ZeroKit-Android-SDK
sample/src/main/java/com/tresorit/zerokitsdk/viewmodel/EncryptViewModel.java
// Path: sample/src/main/java/com/tresorit/zerokitsdk/adapter/EncryptPagerAdapter.java // public class EncryptPagerAdapter extends FragmentPagerAdapter { // // @SuppressWarnings("WeakerAccess") // @Inject // CreateTresorFragment createTresorFragment; // // @SuppressWarnings("WeakerAccess") // @Inject // EncryptTextFragment encryptTextFragment; // // @SuppressWarnings("WeakerAccess") // @Inject // ShareTresorFragment shareTresorFragment; // // // public EncryptPagerAdapter(Context context, FragmentManager fm) { // super(fm); // DaggerPagerComponent.builder().applicationComponent(ZerokitApplication.get(context).component()).build().inject(this); // } // // @Override // public Fragment getItem(int position) { // switch (position){ // case 0: // return createTresorFragment; // case 1: // return encryptTextFragment; // case 2: // return shareTresorFragment; // default: // return new Fragment(); // } // } // // @Override // public int getCount() { // return 3; // } // }
import android.content.Context; import android.databinding.BaseObservable; import android.databinding.ObservableField; import android.graphics.drawable.Drawable; import android.support.v4.app.FragmentManager; import android.support.v4.view.ViewPager; import com.tresorit.zerokitsdk.R; import com.tresorit.zerokitsdk.adapter.EncryptPagerAdapter;
package com.tresorit.zerokitsdk.viewmodel; public class EncryptViewModel extends BaseObservable { @SuppressWarnings("WeakerAccess")
// Path: sample/src/main/java/com/tresorit/zerokitsdk/adapter/EncryptPagerAdapter.java // public class EncryptPagerAdapter extends FragmentPagerAdapter { // // @SuppressWarnings("WeakerAccess") // @Inject // CreateTresorFragment createTresorFragment; // // @SuppressWarnings("WeakerAccess") // @Inject // EncryptTextFragment encryptTextFragment; // // @SuppressWarnings("WeakerAccess") // @Inject // ShareTresorFragment shareTresorFragment; // // // public EncryptPagerAdapter(Context context, FragmentManager fm) { // super(fm); // DaggerPagerComponent.builder().applicationComponent(ZerokitApplication.get(context).component()).build().inject(this); // } // // @Override // public Fragment getItem(int position) { // switch (position){ // case 0: // return createTresorFragment; // case 1: // return encryptTextFragment; // case 2: // return shareTresorFragment; // default: // return new Fragment(); // } // } // // @Override // public int getCount() { // return 3; // } // } // Path: sample/src/main/java/com/tresorit/zerokitsdk/viewmodel/EncryptViewModel.java import android.content.Context; import android.databinding.BaseObservable; import android.databinding.ObservableField; import android.graphics.drawable.Drawable; import android.support.v4.app.FragmentManager; import android.support.v4.view.ViewPager; import com.tresorit.zerokitsdk.R; import com.tresorit.zerokitsdk.adapter.EncryptPagerAdapter; package com.tresorit.zerokitsdk.viewmodel; public class EncryptViewModel extends BaseObservable { @SuppressWarnings("WeakerAccess")
public final EncryptPagerAdapter pagerAdapter;
tresorit/ZeroKit-Android-SDK
zerokit/src/main/java/com/tresorit/zerokit/response/CrackTimesSeconds.java
// Path: zerokit/src/main/java/com/tresorit/zerokit/util/JSONObject.java // public class JSONObject { // // private org.json.JSONObject jsonObject; // // public JSONObject() { // jsonObject = new org.json.JSONObject(); // } // // public JSONObject(String json) { // try { // jsonObject = new org.json.JSONObject(json); // } catch (JSONException e) { // //e.printStackTrace(); // jsonObject = new org.json.JSONObject(); // } // } // // public org.json.JSONObject getJSONObject(String name) { // if (jsonObject != null) // try { // return jsonObject.getJSONObject(name); // } catch (JSONException e) { // //e.printStackTrace(); // } // return new org.json.JSONObject(); // } // // // public String getString(String name) { // if (jsonObject != null) // try { // return jsonObject.getString(name); // } catch (JSONException e) { // //e.printStackTrace(); // } // return ""; // } // // public double getDouble(String name) { // if (jsonObject != null) // try { // return jsonObject.getDouble(name); // } catch (JSONException e) { // //e.printStackTrace(); // } // return 0; // } // // public int getInt(String name) { // if (jsonObject != null) // try { // return jsonObject.getInt(name); // } catch (JSONException e) { // //e.printStackTrace(); // } // return 0; // } // // public List<String> getStringArray(String name) { // if (jsonObject != null) // try { // JSONArray jsonArray = jsonObject.getJSONArray(name); // List<String> result = new ArrayList<>(); // for (int i = 0; i < jsonArray.length(); i++) // result.add(jsonArray.getString(i)); // return result; // } catch (JSONException e) { // //e.printStackTrace(); // } // return new ArrayList<>(); // } // // public JSONObject put(String name, Object value) { // if (jsonObject != null) // try { // jsonObject.put(name, value); // } catch (JSONException e) { // //e.printStackTrace(); // } // return this; // } // // @Override // public String toString() { // return jsonObject != null ? jsonObject.toString() : ""; // } // } // // Path: common/src/main/java/com/tresorit/zerokit/util/ZerokitJson.java // public abstract class ZerokitJson { // // public abstract <T extends ZerokitJson> T parse(String json); // // }
import com.tresorit.zerokit.util.JSONObject; import com.tresorit.zerokit.util.ZerokitJson;
package com.tresorit.zerokit.response; public class CrackTimesSeconds extends ZerokitJson { private double online_throttling_100_per_hour; private double online_no_throttling_10_per_second; private double offline_slow_hashing_1e4_per_second; private double offline_fast_hashing_1e10_per_second; public double getOffline_fast_hashing_1e10_per_second() { return offline_fast_hashing_1e10_per_second; } public double getOffline_slow_hashing_1e4_per_second() { return offline_slow_hashing_1e4_per_second; } public double getOnline_no_throttling_10_per_second() { return online_no_throttling_10_per_second; } public double getOnline_throttling_100_per_hour() { return online_throttling_100_per_hour; } @Override public String toString() { return String.format("offline_fast_hashing_1e10_per_second: %s, offline_slow_hashing_1e4_per_second: %s, online_no_throttling_10_per_second: %s, online_throttling_100_per_hour: %s", offline_fast_hashing_1e10_per_second, offline_slow_hashing_1e4_per_second, online_no_throttling_10_per_second, online_throttling_100_per_hour); } @SuppressWarnings("unchecked") @Override public <T extends ZerokitJson> T parse(String json) {
// Path: zerokit/src/main/java/com/tresorit/zerokit/util/JSONObject.java // public class JSONObject { // // private org.json.JSONObject jsonObject; // // public JSONObject() { // jsonObject = new org.json.JSONObject(); // } // // public JSONObject(String json) { // try { // jsonObject = new org.json.JSONObject(json); // } catch (JSONException e) { // //e.printStackTrace(); // jsonObject = new org.json.JSONObject(); // } // } // // public org.json.JSONObject getJSONObject(String name) { // if (jsonObject != null) // try { // return jsonObject.getJSONObject(name); // } catch (JSONException e) { // //e.printStackTrace(); // } // return new org.json.JSONObject(); // } // // // public String getString(String name) { // if (jsonObject != null) // try { // return jsonObject.getString(name); // } catch (JSONException e) { // //e.printStackTrace(); // } // return ""; // } // // public double getDouble(String name) { // if (jsonObject != null) // try { // return jsonObject.getDouble(name); // } catch (JSONException e) { // //e.printStackTrace(); // } // return 0; // } // // public int getInt(String name) { // if (jsonObject != null) // try { // return jsonObject.getInt(name); // } catch (JSONException e) { // //e.printStackTrace(); // } // return 0; // } // // public List<String> getStringArray(String name) { // if (jsonObject != null) // try { // JSONArray jsonArray = jsonObject.getJSONArray(name); // List<String> result = new ArrayList<>(); // for (int i = 0; i < jsonArray.length(); i++) // result.add(jsonArray.getString(i)); // return result; // } catch (JSONException e) { // //e.printStackTrace(); // } // return new ArrayList<>(); // } // // public JSONObject put(String name, Object value) { // if (jsonObject != null) // try { // jsonObject.put(name, value); // } catch (JSONException e) { // //e.printStackTrace(); // } // return this; // } // // @Override // public String toString() { // return jsonObject != null ? jsonObject.toString() : ""; // } // } // // Path: common/src/main/java/com/tresorit/zerokit/util/ZerokitJson.java // public abstract class ZerokitJson { // // public abstract <T extends ZerokitJson> T parse(String json); // // } // Path: zerokit/src/main/java/com/tresorit/zerokit/response/CrackTimesSeconds.java import com.tresorit.zerokit.util.JSONObject; import com.tresorit.zerokit.util.ZerokitJson; package com.tresorit.zerokit.response; public class CrackTimesSeconds extends ZerokitJson { private double online_throttling_100_per_hour; private double online_no_throttling_10_per_second; private double offline_slow_hashing_1e4_per_second; private double offline_fast_hashing_1e10_per_second; public double getOffline_fast_hashing_1e10_per_second() { return offline_fast_hashing_1e10_per_second; } public double getOffline_slow_hashing_1e4_per_second() { return offline_slow_hashing_1e4_per_second; } public double getOnline_no_throttling_10_per_second() { return online_no_throttling_10_per_second; } public double getOnline_throttling_100_per_hour() { return online_throttling_100_per_hour; } @Override public String toString() { return String.format("offline_fast_hashing_1e10_per_second: %s, offline_slow_hashing_1e4_per_second: %s, online_no_throttling_10_per_second: %s, online_throttling_100_per_hour: %s", offline_fast_hashing_1e10_per_second, offline_slow_hashing_1e4_per_second, online_no_throttling_10_per_second, online_throttling_100_per_hour); } @SuppressWarnings("unchecked") @Override public <T extends ZerokitJson> T parse(String json) {
JSONObject jsonObject = new JSONObject(json);
tresorit/ZeroKit-Android-SDK
sample/src/main/java/com/tresorit/zerokitsdk/component/ShareTresorComponent.java
// Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/ShareTresorFragment.java // public class ShareTresorFragment extends Fragment { // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // ShareTresorViewModel viewModel; // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // EventBus eventBus; // // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // DaggerShareTresorComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentShareTresorBinding binding = FragmentShareTresorBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // // @Override // public void onStart() { // super.onStart(); // eventBus.register(viewModel); // } // // @Override // public void onStop() { // super.onStop(); // eventBus.unregister(viewModel); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/ShareTresorModule.java // @Module // public class ShareTresorModule { // @Provides // @ActivityScope // public ShareTresorViewModel provideShareTresorViewModel(Zerokit zerokit, AdminApi adminApi, EventBus eventBus) { // return new ShareTresorViewModel(zerokit, adminApi, eventBus); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/viewmodel/ShareTresorViewModel.java // public class ShareTresorViewModel extends BaseObservable { // // @SuppressWarnings("WeakerAccess") // public final View.OnClickListener clickListener; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Boolean> inProgress; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> userId; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> textSummary; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> sharedWithUserId; // // @SuppressWarnings("WeakerAccess") // final Action<ResponseZerokitError> errorResponseHandlerSdk; // @SuppressWarnings("WeakerAccess") // final Action<ResponseAdminApiError> errorResponseHandlerAdminapi; // // final Zerokit zerokit; // // @SuppressWarnings("WeakerAccess") // final AdminApi adminApi; // // @SuppressWarnings("WeakerAccess") // String tresorId; // // @Inject // public ShareTresorViewModel(Zerokit zerokit, AdminApi adminApi, final EventBus eventBus) { // this.zerokit = zerokit; // this.adminApi = adminApi; // // this.inProgress = new ObservableField<>(false); // this.userId = new ObservableField<>(); // this.textSummary = new ObservableField<>(); // this.sharedWithUserId = new ObservableField<>(""); // this.clickListener = new View.OnClickListener() { // @Override // public void onClick(View v) { // shareTresor(tresorId, userId.get()); // } // }; // errorResponseHandlerSdk = new Action<ResponseZerokitError>() { // @Override // public void call(ResponseZerokitError errorResponse) { // inProgress.set(false); // eventBus.post(new ShowMessageMessage(errorResponse.toString())); // } // }; // errorResponseHandlerAdminapi = new Action<ResponseAdminApiError>() { // @Override // public void call(ResponseAdminApiError errorResponse) { // inProgress.set(false); // eventBus.post(new ShowMessageMessage(errorResponse.toString())); // } // }; // } // // @SuppressWarnings("WeakerAccess") // void shareTresor(final String tresorId, final String userName) { // inProgress.set(true); // sharedWithUserId.set(""); // this.adminApi.getUserId(userName).enqueue(new Action<String>() { // @Override // public void call(String userId) { // zerokit.shareTresor(tresorId, userId).enqueue(new Action<String>() { // @Override // public void call(String shareId) { // adminApi.sharedTresor(shareId).enqueue(new Action<Void>() { // @Override // public void call(Void result) { // sharedWithUserId.set("Shared with: " + userName); // inProgress.set(false); // } // }, errorResponseHandlerAdminapi); // } // }, errorResponseHandlerSdk); // } // }, errorResponseHandlerAdminapi); // } // // @Subscribe // @SuppressWarnings("unused") // public void onEvent(CreateTresorFinishedMessage message) { // tresorId = message.getTresorId(); // textSummary.set("Tresor ID: " + message.getTresorId()); // sharedWithUserId.set(""); // } // // }
import com.tresorit.zerokitsdk.fragment.ShareTresorFragment; import com.tresorit.zerokitsdk.module.ShareTresorModule; import com.tresorit.zerokitsdk.scopes.ActivityScope; import com.tresorit.zerokitsdk.viewmodel.ShareTresorViewModel; import dagger.Component;
package com.tresorit.zerokitsdk.component; @ActivityScope @Component( modules = {
// Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/ShareTresorFragment.java // public class ShareTresorFragment extends Fragment { // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // ShareTresorViewModel viewModel; // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // EventBus eventBus; // // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // DaggerShareTresorComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentShareTresorBinding binding = FragmentShareTresorBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // // @Override // public void onStart() { // super.onStart(); // eventBus.register(viewModel); // } // // @Override // public void onStop() { // super.onStop(); // eventBus.unregister(viewModel); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/ShareTresorModule.java // @Module // public class ShareTresorModule { // @Provides // @ActivityScope // public ShareTresorViewModel provideShareTresorViewModel(Zerokit zerokit, AdminApi adminApi, EventBus eventBus) { // return new ShareTresorViewModel(zerokit, adminApi, eventBus); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/viewmodel/ShareTresorViewModel.java // public class ShareTresorViewModel extends BaseObservable { // // @SuppressWarnings("WeakerAccess") // public final View.OnClickListener clickListener; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Boolean> inProgress; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> userId; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> textSummary; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> sharedWithUserId; // // @SuppressWarnings("WeakerAccess") // final Action<ResponseZerokitError> errorResponseHandlerSdk; // @SuppressWarnings("WeakerAccess") // final Action<ResponseAdminApiError> errorResponseHandlerAdminapi; // // final Zerokit zerokit; // // @SuppressWarnings("WeakerAccess") // final AdminApi adminApi; // // @SuppressWarnings("WeakerAccess") // String tresorId; // // @Inject // public ShareTresorViewModel(Zerokit zerokit, AdminApi adminApi, final EventBus eventBus) { // this.zerokit = zerokit; // this.adminApi = adminApi; // // this.inProgress = new ObservableField<>(false); // this.userId = new ObservableField<>(); // this.textSummary = new ObservableField<>(); // this.sharedWithUserId = new ObservableField<>(""); // this.clickListener = new View.OnClickListener() { // @Override // public void onClick(View v) { // shareTresor(tresorId, userId.get()); // } // }; // errorResponseHandlerSdk = new Action<ResponseZerokitError>() { // @Override // public void call(ResponseZerokitError errorResponse) { // inProgress.set(false); // eventBus.post(new ShowMessageMessage(errorResponse.toString())); // } // }; // errorResponseHandlerAdminapi = new Action<ResponseAdminApiError>() { // @Override // public void call(ResponseAdminApiError errorResponse) { // inProgress.set(false); // eventBus.post(new ShowMessageMessage(errorResponse.toString())); // } // }; // } // // @SuppressWarnings("WeakerAccess") // void shareTresor(final String tresorId, final String userName) { // inProgress.set(true); // sharedWithUserId.set(""); // this.adminApi.getUserId(userName).enqueue(new Action<String>() { // @Override // public void call(String userId) { // zerokit.shareTresor(tresorId, userId).enqueue(new Action<String>() { // @Override // public void call(String shareId) { // adminApi.sharedTresor(shareId).enqueue(new Action<Void>() { // @Override // public void call(Void result) { // sharedWithUserId.set("Shared with: " + userName); // inProgress.set(false); // } // }, errorResponseHandlerAdminapi); // } // }, errorResponseHandlerSdk); // } // }, errorResponseHandlerAdminapi); // } // // @Subscribe // @SuppressWarnings("unused") // public void onEvent(CreateTresorFinishedMessage message) { // tresorId = message.getTresorId(); // textSummary.set("Tresor ID: " + message.getTresorId()); // sharedWithUserId.set(""); // } // // } // Path: sample/src/main/java/com/tresorit/zerokitsdk/component/ShareTresorComponent.java import com.tresorit.zerokitsdk.fragment.ShareTresorFragment; import com.tresorit.zerokitsdk.module.ShareTresorModule; import com.tresorit.zerokitsdk.scopes.ActivityScope; import com.tresorit.zerokitsdk.viewmodel.ShareTresorViewModel; import dagger.Component; package com.tresorit.zerokitsdk.component; @ActivityScope @Component( modules = {
ShareTresorModule.class
tresorit/ZeroKit-Android-SDK
sample/src/main/java/com/tresorit/zerokitsdk/component/ShareTresorComponent.java
// Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/ShareTresorFragment.java // public class ShareTresorFragment extends Fragment { // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // ShareTresorViewModel viewModel; // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // EventBus eventBus; // // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // DaggerShareTresorComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentShareTresorBinding binding = FragmentShareTresorBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // // @Override // public void onStart() { // super.onStart(); // eventBus.register(viewModel); // } // // @Override // public void onStop() { // super.onStop(); // eventBus.unregister(viewModel); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/ShareTresorModule.java // @Module // public class ShareTresorModule { // @Provides // @ActivityScope // public ShareTresorViewModel provideShareTresorViewModel(Zerokit zerokit, AdminApi adminApi, EventBus eventBus) { // return new ShareTresorViewModel(zerokit, adminApi, eventBus); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/viewmodel/ShareTresorViewModel.java // public class ShareTresorViewModel extends BaseObservable { // // @SuppressWarnings("WeakerAccess") // public final View.OnClickListener clickListener; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Boolean> inProgress; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> userId; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> textSummary; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> sharedWithUserId; // // @SuppressWarnings("WeakerAccess") // final Action<ResponseZerokitError> errorResponseHandlerSdk; // @SuppressWarnings("WeakerAccess") // final Action<ResponseAdminApiError> errorResponseHandlerAdminapi; // // final Zerokit zerokit; // // @SuppressWarnings("WeakerAccess") // final AdminApi adminApi; // // @SuppressWarnings("WeakerAccess") // String tresorId; // // @Inject // public ShareTresorViewModel(Zerokit zerokit, AdminApi adminApi, final EventBus eventBus) { // this.zerokit = zerokit; // this.adminApi = adminApi; // // this.inProgress = new ObservableField<>(false); // this.userId = new ObservableField<>(); // this.textSummary = new ObservableField<>(); // this.sharedWithUserId = new ObservableField<>(""); // this.clickListener = new View.OnClickListener() { // @Override // public void onClick(View v) { // shareTresor(tresorId, userId.get()); // } // }; // errorResponseHandlerSdk = new Action<ResponseZerokitError>() { // @Override // public void call(ResponseZerokitError errorResponse) { // inProgress.set(false); // eventBus.post(new ShowMessageMessage(errorResponse.toString())); // } // }; // errorResponseHandlerAdminapi = new Action<ResponseAdminApiError>() { // @Override // public void call(ResponseAdminApiError errorResponse) { // inProgress.set(false); // eventBus.post(new ShowMessageMessage(errorResponse.toString())); // } // }; // } // // @SuppressWarnings("WeakerAccess") // void shareTresor(final String tresorId, final String userName) { // inProgress.set(true); // sharedWithUserId.set(""); // this.adminApi.getUserId(userName).enqueue(new Action<String>() { // @Override // public void call(String userId) { // zerokit.shareTresor(tresorId, userId).enqueue(new Action<String>() { // @Override // public void call(String shareId) { // adminApi.sharedTresor(shareId).enqueue(new Action<Void>() { // @Override // public void call(Void result) { // sharedWithUserId.set("Shared with: " + userName); // inProgress.set(false); // } // }, errorResponseHandlerAdminapi); // } // }, errorResponseHandlerSdk); // } // }, errorResponseHandlerAdminapi); // } // // @Subscribe // @SuppressWarnings("unused") // public void onEvent(CreateTresorFinishedMessage message) { // tresorId = message.getTresorId(); // textSummary.set("Tresor ID: " + message.getTresorId()); // sharedWithUserId.set(""); // } // // }
import com.tresorit.zerokitsdk.fragment.ShareTresorFragment; import com.tresorit.zerokitsdk.module.ShareTresorModule; import com.tresorit.zerokitsdk.scopes.ActivityScope; import com.tresorit.zerokitsdk.viewmodel.ShareTresorViewModel; import dagger.Component;
package com.tresorit.zerokitsdk.component; @ActivityScope @Component( modules = { ShareTresorModule.class }, dependencies = { ApplicationComponent.class } ) public interface ShareTresorComponent {
// Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/ShareTresorFragment.java // public class ShareTresorFragment extends Fragment { // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // ShareTresorViewModel viewModel; // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // EventBus eventBus; // // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // DaggerShareTresorComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentShareTresorBinding binding = FragmentShareTresorBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // // @Override // public void onStart() { // super.onStart(); // eventBus.register(viewModel); // } // // @Override // public void onStop() { // super.onStop(); // eventBus.unregister(viewModel); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/ShareTresorModule.java // @Module // public class ShareTresorModule { // @Provides // @ActivityScope // public ShareTresorViewModel provideShareTresorViewModel(Zerokit zerokit, AdminApi adminApi, EventBus eventBus) { // return new ShareTresorViewModel(zerokit, adminApi, eventBus); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/viewmodel/ShareTresorViewModel.java // public class ShareTresorViewModel extends BaseObservable { // // @SuppressWarnings("WeakerAccess") // public final View.OnClickListener clickListener; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Boolean> inProgress; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> userId; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> textSummary; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> sharedWithUserId; // // @SuppressWarnings("WeakerAccess") // final Action<ResponseZerokitError> errorResponseHandlerSdk; // @SuppressWarnings("WeakerAccess") // final Action<ResponseAdminApiError> errorResponseHandlerAdminapi; // // final Zerokit zerokit; // // @SuppressWarnings("WeakerAccess") // final AdminApi adminApi; // // @SuppressWarnings("WeakerAccess") // String tresorId; // // @Inject // public ShareTresorViewModel(Zerokit zerokit, AdminApi adminApi, final EventBus eventBus) { // this.zerokit = zerokit; // this.adminApi = adminApi; // // this.inProgress = new ObservableField<>(false); // this.userId = new ObservableField<>(); // this.textSummary = new ObservableField<>(); // this.sharedWithUserId = new ObservableField<>(""); // this.clickListener = new View.OnClickListener() { // @Override // public void onClick(View v) { // shareTresor(tresorId, userId.get()); // } // }; // errorResponseHandlerSdk = new Action<ResponseZerokitError>() { // @Override // public void call(ResponseZerokitError errorResponse) { // inProgress.set(false); // eventBus.post(new ShowMessageMessage(errorResponse.toString())); // } // }; // errorResponseHandlerAdminapi = new Action<ResponseAdminApiError>() { // @Override // public void call(ResponseAdminApiError errorResponse) { // inProgress.set(false); // eventBus.post(new ShowMessageMessage(errorResponse.toString())); // } // }; // } // // @SuppressWarnings("WeakerAccess") // void shareTresor(final String tresorId, final String userName) { // inProgress.set(true); // sharedWithUserId.set(""); // this.adminApi.getUserId(userName).enqueue(new Action<String>() { // @Override // public void call(String userId) { // zerokit.shareTresor(tresorId, userId).enqueue(new Action<String>() { // @Override // public void call(String shareId) { // adminApi.sharedTresor(shareId).enqueue(new Action<Void>() { // @Override // public void call(Void result) { // sharedWithUserId.set("Shared with: " + userName); // inProgress.set(false); // } // }, errorResponseHandlerAdminapi); // } // }, errorResponseHandlerSdk); // } // }, errorResponseHandlerAdminapi); // } // // @Subscribe // @SuppressWarnings("unused") // public void onEvent(CreateTresorFinishedMessage message) { // tresorId = message.getTresorId(); // textSummary.set("Tresor ID: " + message.getTresorId()); // sharedWithUserId.set(""); // } // // } // Path: sample/src/main/java/com/tresorit/zerokitsdk/component/ShareTresorComponent.java import com.tresorit.zerokitsdk.fragment.ShareTresorFragment; import com.tresorit.zerokitsdk.module.ShareTresorModule; import com.tresorit.zerokitsdk.scopes.ActivityScope; import com.tresorit.zerokitsdk.viewmodel.ShareTresorViewModel; import dagger.Component; package com.tresorit.zerokitsdk.component; @ActivityScope @Component( modules = { ShareTresorModule.class }, dependencies = { ApplicationComponent.class } ) public interface ShareTresorComponent {
void inject(ShareTresorFragment fragment);
tresorit/ZeroKit-Android-SDK
sample/src/main/java/com/tresorit/zerokitsdk/component/ShareTresorComponent.java
// Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/ShareTresorFragment.java // public class ShareTresorFragment extends Fragment { // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // ShareTresorViewModel viewModel; // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // EventBus eventBus; // // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // DaggerShareTresorComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentShareTresorBinding binding = FragmentShareTresorBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // // @Override // public void onStart() { // super.onStart(); // eventBus.register(viewModel); // } // // @Override // public void onStop() { // super.onStop(); // eventBus.unregister(viewModel); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/ShareTresorModule.java // @Module // public class ShareTresorModule { // @Provides // @ActivityScope // public ShareTresorViewModel provideShareTresorViewModel(Zerokit zerokit, AdminApi adminApi, EventBus eventBus) { // return new ShareTresorViewModel(zerokit, adminApi, eventBus); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/viewmodel/ShareTresorViewModel.java // public class ShareTresorViewModel extends BaseObservable { // // @SuppressWarnings("WeakerAccess") // public final View.OnClickListener clickListener; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Boolean> inProgress; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> userId; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> textSummary; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> sharedWithUserId; // // @SuppressWarnings("WeakerAccess") // final Action<ResponseZerokitError> errorResponseHandlerSdk; // @SuppressWarnings("WeakerAccess") // final Action<ResponseAdminApiError> errorResponseHandlerAdminapi; // // final Zerokit zerokit; // // @SuppressWarnings("WeakerAccess") // final AdminApi adminApi; // // @SuppressWarnings("WeakerAccess") // String tresorId; // // @Inject // public ShareTresorViewModel(Zerokit zerokit, AdminApi adminApi, final EventBus eventBus) { // this.zerokit = zerokit; // this.adminApi = adminApi; // // this.inProgress = new ObservableField<>(false); // this.userId = new ObservableField<>(); // this.textSummary = new ObservableField<>(); // this.sharedWithUserId = new ObservableField<>(""); // this.clickListener = new View.OnClickListener() { // @Override // public void onClick(View v) { // shareTresor(tresorId, userId.get()); // } // }; // errorResponseHandlerSdk = new Action<ResponseZerokitError>() { // @Override // public void call(ResponseZerokitError errorResponse) { // inProgress.set(false); // eventBus.post(new ShowMessageMessage(errorResponse.toString())); // } // }; // errorResponseHandlerAdminapi = new Action<ResponseAdminApiError>() { // @Override // public void call(ResponseAdminApiError errorResponse) { // inProgress.set(false); // eventBus.post(new ShowMessageMessage(errorResponse.toString())); // } // }; // } // // @SuppressWarnings("WeakerAccess") // void shareTresor(final String tresorId, final String userName) { // inProgress.set(true); // sharedWithUserId.set(""); // this.adminApi.getUserId(userName).enqueue(new Action<String>() { // @Override // public void call(String userId) { // zerokit.shareTresor(tresorId, userId).enqueue(new Action<String>() { // @Override // public void call(String shareId) { // adminApi.sharedTresor(shareId).enqueue(new Action<Void>() { // @Override // public void call(Void result) { // sharedWithUserId.set("Shared with: " + userName); // inProgress.set(false); // } // }, errorResponseHandlerAdminapi); // } // }, errorResponseHandlerSdk); // } // }, errorResponseHandlerAdminapi); // } // // @Subscribe // @SuppressWarnings("unused") // public void onEvent(CreateTresorFinishedMessage message) { // tresorId = message.getTresorId(); // textSummary.set("Tresor ID: " + message.getTresorId()); // sharedWithUserId.set(""); // } // // }
import com.tresorit.zerokitsdk.fragment.ShareTresorFragment; import com.tresorit.zerokitsdk.module.ShareTresorModule; import com.tresorit.zerokitsdk.scopes.ActivityScope; import com.tresorit.zerokitsdk.viewmodel.ShareTresorViewModel; import dagger.Component;
package com.tresorit.zerokitsdk.component; @ActivityScope @Component( modules = { ShareTresorModule.class }, dependencies = { ApplicationComponent.class } ) public interface ShareTresorComponent { void inject(ShareTresorFragment fragment);
// Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/ShareTresorFragment.java // public class ShareTresorFragment extends Fragment { // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // ShareTresorViewModel viewModel; // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // EventBus eventBus; // // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // DaggerShareTresorComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentShareTresorBinding binding = FragmentShareTresorBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // // @Override // public void onStart() { // super.onStart(); // eventBus.register(viewModel); // } // // @Override // public void onStop() { // super.onStop(); // eventBus.unregister(viewModel); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/ShareTresorModule.java // @Module // public class ShareTresorModule { // @Provides // @ActivityScope // public ShareTresorViewModel provideShareTresorViewModel(Zerokit zerokit, AdminApi adminApi, EventBus eventBus) { // return new ShareTresorViewModel(zerokit, adminApi, eventBus); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/viewmodel/ShareTresorViewModel.java // public class ShareTresorViewModel extends BaseObservable { // // @SuppressWarnings("WeakerAccess") // public final View.OnClickListener clickListener; // @SuppressWarnings("WeakerAccess") // public final ObservableField<Boolean> inProgress; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> userId; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> textSummary; // @SuppressWarnings("WeakerAccess") // public final ObservableField<String> sharedWithUserId; // // @SuppressWarnings("WeakerAccess") // final Action<ResponseZerokitError> errorResponseHandlerSdk; // @SuppressWarnings("WeakerAccess") // final Action<ResponseAdminApiError> errorResponseHandlerAdminapi; // // final Zerokit zerokit; // // @SuppressWarnings("WeakerAccess") // final AdminApi adminApi; // // @SuppressWarnings("WeakerAccess") // String tresorId; // // @Inject // public ShareTresorViewModel(Zerokit zerokit, AdminApi adminApi, final EventBus eventBus) { // this.zerokit = zerokit; // this.adminApi = adminApi; // // this.inProgress = new ObservableField<>(false); // this.userId = new ObservableField<>(); // this.textSummary = new ObservableField<>(); // this.sharedWithUserId = new ObservableField<>(""); // this.clickListener = new View.OnClickListener() { // @Override // public void onClick(View v) { // shareTresor(tresorId, userId.get()); // } // }; // errorResponseHandlerSdk = new Action<ResponseZerokitError>() { // @Override // public void call(ResponseZerokitError errorResponse) { // inProgress.set(false); // eventBus.post(new ShowMessageMessage(errorResponse.toString())); // } // }; // errorResponseHandlerAdminapi = new Action<ResponseAdminApiError>() { // @Override // public void call(ResponseAdminApiError errorResponse) { // inProgress.set(false); // eventBus.post(new ShowMessageMessage(errorResponse.toString())); // } // }; // } // // @SuppressWarnings("WeakerAccess") // void shareTresor(final String tresorId, final String userName) { // inProgress.set(true); // sharedWithUserId.set(""); // this.adminApi.getUserId(userName).enqueue(new Action<String>() { // @Override // public void call(String userId) { // zerokit.shareTresor(tresorId, userId).enqueue(new Action<String>() { // @Override // public void call(String shareId) { // adminApi.sharedTresor(shareId).enqueue(new Action<Void>() { // @Override // public void call(Void result) { // sharedWithUserId.set("Shared with: " + userName); // inProgress.set(false); // } // }, errorResponseHandlerAdminapi); // } // }, errorResponseHandlerSdk); // } // }, errorResponseHandlerAdminapi); // } // // @Subscribe // @SuppressWarnings("unused") // public void onEvent(CreateTresorFinishedMessage message) { // tresorId = message.getTresorId(); // textSummary.set("Tresor ID: " + message.getTresorId()); // sharedWithUserId.set(""); // } // // } // Path: sample/src/main/java/com/tresorit/zerokitsdk/component/ShareTresorComponent.java import com.tresorit.zerokitsdk.fragment.ShareTresorFragment; import com.tresorit.zerokitsdk.module.ShareTresorModule; import com.tresorit.zerokitsdk.scopes.ActivityScope; import com.tresorit.zerokitsdk.viewmodel.ShareTresorViewModel; import dagger.Component; package com.tresorit.zerokitsdk.component; @ActivityScope @Component( modules = { ShareTresorModule.class }, dependencies = { ApplicationComponent.class } ) public interface ShareTresorComponent { void inject(ShareTresorFragment fragment);
ShareTresorViewModel viewmodel();
tresorit/ZeroKit-Android-SDK
zerokit/src/main/java/com/tresorit/zerokit/response/ResponseZerokitChangePassword.java
// Path: zerokit/src/main/java/com/tresorit/zerokit/util/JSONObject.java // public class JSONObject { // // private org.json.JSONObject jsonObject; // // public JSONObject() { // jsonObject = new org.json.JSONObject(); // } // // public JSONObject(String json) { // try { // jsonObject = new org.json.JSONObject(json); // } catch (JSONException e) { // //e.printStackTrace(); // jsonObject = new org.json.JSONObject(); // } // } // // public org.json.JSONObject getJSONObject(String name) { // if (jsonObject != null) // try { // return jsonObject.getJSONObject(name); // } catch (JSONException e) { // //e.printStackTrace(); // } // return new org.json.JSONObject(); // } // // // public String getString(String name) { // if (jsonObject != null) // try { // return jsonObject.getString(name); // } catch (JSONException e) { // //e.printStackTrace(); // } // return ""; // } // // public double getDouble(String name) { // if (jsonObject != null) // try { // return jsonObject.getDouble(name); // } catch (JSONException e) { // //e.printStackTrace(); // } // return 0; // } // // public int getInt(String name) { // if (jsonObject != null) // try { // return jsonObject.getInt(name); // } catch (JSONException e) { // //e.printStackTrace(); // } // return 0; // } // // public List<String> getStringArray(String name) { // if (jsonObject != null) // try { // JSONArray jsonArray = jsonObject.getJSONArray(name); // List<String> result = new ArrayList<>(); // for (int i = 0; i < jsonArray.length(); i++) // result.add(jsonArray.getString(i)); // return result; // } catch (JSONException e) { // //e.printStackTrace(); // } // return new ArrayList<>(); // } // // public JSONObject put(String name, Object value) { // if (jsonObject != null) // try { // jsonObject.put(name, value); // } catch (JSONException e) { // //e.printStackTrace(); // } // return this; // } // // @Override // public String toString() { // return jsonObject != null ? jsonObject.toString() : ""; // } // } // // Path: common/src/main/java/com/tresorit/zerokit/util/ZerokitJson.java // public abstract class ZerokitJson { // // public abstract <T extends ZerokitJson> T parse(String json); // // }
import com.tresorit.zerokit.util.JSONObject; import com.tresorit.zerokit.util.ZerokitJson;
package com.tresorit.zerokit.response; public class ResponseZerokitChangePassword extends ZerokitJson { private int MasterFragmentVersion; public int getMasterFragmentVersion() { return MasterFragmentVersion; } @SuppressWarnings("unchecked") @Override public ResponseZerokitChangePassword parse(String json) {
// Path: zerokit/src/main/java/com/tresorit/zerokit/util/JSONObject.java // public class JSONObject { // // private org.json.JSONObject jsonObject; // // public JSONObject() { // jsonObject = new org.json.JSONObject(); // } // // public JSONObject(String json) { // try { // jsonObject = new org.json.JSONObject(json); // } catch (JSONException e) { // //e.printStackTrace(); // jsonObject = new org.json.JSONObject(); // } // } // // public org.json.JSONObject getJSONObject(String name) { // if (jsonObject != null) // try { // return jsonObject.getJSONObject(name); // } catch (JSONException e) { // //e.printStackTrace(); // } // return new org.json.JSONObject(); // } // // // public String getString(String name) { // if (jsonObject != null) // try { // return jsonObject.getString(name); // } catch (JSONException e) { // //e.printStackTrace(); // } // return ""; // } // // public double getDouble(String name) { // if (jsonObject != null) // try { // return jsonObject.getDouble(name); // } catch (JSONException e) { // //e.printStackTrace(); // } // return 0; // } // // public int getInt(String name) { // if (jsonObject != null) // try { // return jsonObject.getInt(name); // } catch (JSONException e) { // //e.printStackTrace(); // } // return 0; // } // // public List<String> getStringArray(String name) { // if (jsonObject != null) // try { // JSONArray jsonArray = jsonObject.getJSONArray(name); // List<String> result = new ArrayList<>(); // for (int i = 0; i < jsonArray.length(); i++) // result.add(jsonArray.getString(i)); // return result; // } catch (JSONException e) { // //e.printStackTrace(); // } // return new ArrayList<>(); // } // // public JSONObject put(String name, Object value) { // if (jsonObject != null) // try { // jsonObject.put(name, value); // } catch (JSONException e) { // //e.printStackTrace(); // } // return this; // } // // @Override // public String toString() { // return jsonObject != null ? jsonObject.toString() : ""; // } // } // // Path: common/src/main/java/com/tresorit/zerokit/util/ZerokitJson.java // public abstract class ZerokitJson { // // public abstract <T extends ZerokitJson> T parse(String json); // // } // Path: zerokit/src/main/java/com/tresorit/zerokit/response/ResponseZerokitChangePassword.java import com.tresorit.zerokit.util.JSONObject; import com.tresorit.zerokit.util.ZerokitJson; package com.tresorit.zerokit.response; public class ResponseZerokitChangePassword extends ZerokitJson { private int MasterFragmentVersion; public int getMasterFragmentVersion() { return MasterFragmentVersion; } @SuppressWarnings("unchecked") @Override public ResponseZerokitChangePassword parse(String json) {
JSONObject jsonobject = new JSONObject(json);
tresorit/ZeroKit-Android-SDK
sample/src/main/java/com/tresorit/zerokitsdk/module/PagerModule.java
// Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/CreateTresorFragment.java // public class CreateTresorFragment extends Fragment { // // @SuppressWarnings("WeakerAccess") // @Inject // CreateTresorViewModel viewModel; // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // DaggerCreateTresorComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentCreateTresorBinding binding = FragmentCreateTresorBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/EncryptTextFragment.java // public class EncryptTextFragment extends Fragment { // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // EncryptTextViewModel viewModel; // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // EventBus eventBus; // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // DaggerEncryptTextComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentEncryptTextBinding binding = FragmentEncryptTextBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // // @Override // public void onStart() { // super.onStart(); // eventBus.register(viewModel); // } // // @Override // public void onStop() { // super.onStop(); // eventBus.unregister(viewModel); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/ShareTresorFragment.java // public class ShareTresorFragment extends Fragment { // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // ShareTresorViewModel viewModel; // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // EventBus eventBus; // // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // DaggerShareTresorComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentShareTresorBinding binding = FragmentShareTresorBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // // @Override // public void onStart() { // super.onStart(); // eventBus.register(viewModel); // } // // @Override // public void onStop() { // super.onStop(); // eventBus.unregister(viewModel); // } // }
import com.tresorit.zerokitsdk.fragment.CreateTresorFragment; import com.tresorit.zerokitsdk.fragment.EncryptTextFragment; import com.tresorit.zerokitsdk.fragment.ShareTresorFragment; import com.tresorit.zerokitsdk.scopes.ActivityScope; import dagger.Module; import dagger.Provides;
package com.tresorit.zerokitsdk.module; @Module public class PagerModule { @Provides @ActivityScope
// Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/CreateTresorFragment.java // public class CreateTresorFragment extends Fragment { // // @SuppressWarnings("WeakerAccess") // @Inject // CreateTresorViewModel viewModel; // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // DaggerCreateTresorComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentCreateTresorBinding binding = FragmentCreateTresorBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/EncryptTextFragment.java // public class EncryptTextFragment extends Fragment { // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // EncryptTextViewModel viewModel; // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // EventBus eventBus; // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // DaggerEncryptTextComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentEncryptTextBinding binding = FragmentEncryptTextBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // // @Override // public void onStart() { // super.onStart(); // eventBus.register(viewModel); // } // // @Override // public void onStop() { // super.onStop(); // eventBus.unregister(viewModel); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/ShareTresorFragment.java // public class ShareTresorFragment extends Fragment { // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // ShareTresorViewModel viewModel; // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // EventBus eventBus; // // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // DaggerShareTresorComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentShareTresorBinding binding = FragmentShareTresorBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // // @Override // public void onStart() { // super.onStart(); // eventBus.register(viewModel); // } // // @Override // public void onStop() { // super.onStop(); // eventBus.unregister(viewModel); // } // } // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/PagerModule.java import com.tresorit.zerokitsdk.fragment.CreateTresorFragment; import com.tresorit.zerokitsdk.fragment.EncryptTextFragment; import com.tresorit.zerokitsdk.fragment.ShareTresorFragment; import com.tresorit.zerokitsdk.scopes.ActivityScope; import dagger.Module; import dagger.Provides; package com.tresorit.zerokitsdk.module; @Module public class PagerModule { @Provides @ActivityScope
public CreateTresorFragment provideCreateTresorFragment() {
tresorit/ZeroKit-Android-SDK
sample/src/main/java/com/tresorit/zerokitsdk/module/PagerModule.java
// Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/CreateTresorFragment.java // public class CreateTresorFragment extends Fragment { // // @SuppressWarnings("WeakerAccess") // @Inject // CreateTresorViewModel viewModel; // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // DaggerCreateTresorComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentCreateTresorBinding binding = FragmentCreateTresorBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/EncryptTextFragment.java // public class EncryptTextFragment extends Fragment { // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // EncryptTextViewModel viewModel; // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // EventBus eventBus; // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // DaggerEncryptTextComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentEncryptTextBinding binding = FragmentEncryptTextBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // // @Override // public void onStart() { // super.onStart(); // eventBus.register(viewModel); // } // // @Override // public void onStop() { // super.onStop(); // eventBus.unregister(viewModel); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/ShareTresorFragment.java // public class ShareTresorFragment extends Fragment { // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // ShareTresorViewModel viewModel; // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // EventBus eventBus; // // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // DaggerShareTresorComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentShareTresorBinding binding = FragmentShareTresorBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // // @Override // public void onStart() { // super.onStart(); // eventBus.register(viewModel); // } // // @Override // public void onStop() { // super.onStop(); // eventBus.unregister(viewModel); // } // }
import com.tresorit.zerokitsdk.fragment.CreateTresorFragment; import com.tresorit.zerokitsdk.fragment.EncryptTextFragment; import com.tresorit.zerokitsdk.fragment.ShareTresorFragment; import com.tresorit.zerokitsdk.scopes.ActivityScope; import dagger.Module; import dagger.Provides;
package com.tresorit.zerokitsdk.module; @Module public class PagerModule { @Provides @ActivityScope public CreateTresorFragment provideCreateTresorFragment() { return new CreateTresorFragment(); } @Provides @ActivityScope
// Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/CreateTresorFragment.java // public class CreateTresorFragment extends Fragment { // // @SuppressWarnings("WeakerAccess") // @Inject // CreateTresorViewModel viewModel; // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // DaggerCreateTresorComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentCreateTresorBinding binding = FragmentCreateTresorBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/EncryptTextFragment.java // public class EncryptTextFragment extends Fragment { // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // EncryptTextViewModel viewModel; // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // EventBus eventBus; // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // DaggerEncryptTextComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentEncryptTextBinding binding = FragmentEncryptTextBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // // @Override // public void onStart() { // super.onStart(); // eventBus.register(viewModel); // } // // @Override // public void onStop() { // super.onStop(); // eventBus.unregister(viewModel); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/ShareTresorFragment.java // public class ShareTresorFragment extends Fragment { // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // ShareTresorViewModel viewModel; // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // EventBus eventBus; // // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // DaggerShareTresorComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentShareTresorBinding binding = FragmentShareTresorBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // // @Override // public void onStart() { // super.onStart(); // eventBus.register(viewModel); // } // // @Override // public void onStop() { // super.onStop(); // eventBus.unregister(viewModel); // } // } // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/PagerModule.java import com.tresorit.zerokitsdk.fragment.CreateTresorFragment; import com.tresorit.zerokitsdk.fragment.EncryptTextFragment; import com.tresorit.zerokitsdk.fragment.ShareTresorFragment; import com.tresorit.zerokitsdk.scopes.ActivityScope; import dagger.Module; import dagger.Provides; package com.tresorit.zerokitsdk.module; @Module public class PagerModule { @Provides @ActivityScope public CreateTresorFragment provideCreateTresorFragment() { return new CreateTresorFragment(); } @Provides @ActivityScope
public ShareTresorFragment provideShareTresorFragment() {
tresorit/ZeroKit-Android-SDK
sample/src/main/java/com/tresorit/zerokitsdk/module/PagerModule.java
// Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/CreateTresorFragment.java // public class CreateTresorFragment extends Fragment { // // @SuppressWarnings("WeakerAccess") // @Inject // CreateTresorViewModel viewModel; // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // DaggerCreateTresorComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentCreateTresorBinding binding = FragmentCreateTresorBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/EncryptTextFragment.java // public class EncryptTextFragment extends Fragment { // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // EncryptTextViewModel viewModel; // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // EventBus eventBus; // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // DaggerEncryptTextComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentEncryptTextBinding binding = FragmentEncryptTextBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // // @Override // public void onStart() { // super.onStart(); // eventBus.register(viewModel); // } // // @Override // public void onStop() { // super.onStop(); // eventBus.unregister(viewModel); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/ShareTresorFragment.java // public class ShareTresorFragment extends Fragment { // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // ShareTresorViewModel viewModel; // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // EventBus eventBus; // // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // DaggerShareTresorComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentShareTresorBinding binding = FragmentShareTresorBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // // @Override // public void onStart() { // super.onStart(); // eventBus.register(viewModel); // } // // @Override // public void onStop() { // super.onStop(); // eventBus.unregister(viewModel); // } // }
import com.tresorit.zerokitsdk.fragment.CreateTresorFragment; import com.tresorit.zerokitsdk.fragment.EncryptTextFragment; import com.tresorit.zerokitsdk.fragment.ShareTresorFragment; import com.tresorit.zerokitsdk.scopes.ActivityScope; import dagger.Module; import dagger.Provides;
package com.tresorit.zerokitsdk.module; @Module public class PagerModule { @Provides @ActivityScope public CreateTresorFragment provideCreateTresorFragment() { return new CreateTresorFragment(); } @Provides @ActivityScope public ShareTresorFragment provideShareTresorFragment() { return new ShareTresorFragment(); } @Provides @ActivityScope
// Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/CreateTresorFragment.java // public class CreateTresorFragment extends Fragment { // // @SuppressWarnings("WeakerAccess") // @Inject // CreateTresorViewModel viewModel; // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // DaggerCreateTresorComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentCreateTresorBinding binding = FragmentCreateTresorBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/EncryptTextFragment.java // public class EncryptTextFragment extends Fragment { // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // EncryptTextViewModel viewModel; // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // EventBus eventBus; // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // DaggerEncryptTextComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentEncryptTextBinding binding = FragmentEncryptTextBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // // @Override // public void onStart() { // super.onStart(); // eventBus.register(viewModel); // } // // @Override // public void onStop() { // super.onStop(); // eventBus.unregister(viewModel); // } // } // // Path: sample/src/main/java/com/tresorit/zerokitsdk/fragment/ShareTresorFragment.java // public class ShareTresorFragment extends Fragment { // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // ShareTresorViewModel viewModel; // // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // @Inject // EventBus eventBus; // // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // DaggerShareTresorComponent.builder().applicationComponent(ZerokitApplication.get(getActivity()).component()).build().inject(this); // FragmentShareTresorBinding binding = FragmentShareTresorBinding.inflate(inflater, container, false); // binding.setViewmodel(viewModel); // return binding.getRoot(); // } // // @Override // public void onStart() { // super.onStart(); // eventBus.register(viewModel); // } // // @Override // public void onStop() { // super.onStop(); // eventBus.unregister(viewModel); // } // } // Path: sample/src/main/java/com/tresorit/zerokitsdk/module/PagerModule.java import com.tresorit.zerokitsdk.fragment.CreateTresorFragment; import com.tresorit.zerokitsdk.fragment.EncryptTextFragment; import com.tresorit.zerokitsdk.fragment.ShareTresorFragment; import com.tresorit.zerokitsdk.scopes.ActivityScope; import dagger.Module; import dagger.Provides; package com.tresorit.zerokitsdk.module; @Module public class PagerModule { @Provides @ActivityScope public CreateTresorFragment provideCreateTresorFragment() { return new CreateTresorFragment(); } @Provides @ActivityScope public ShareTresorFragment provideShareTresorFragment() { return new ShareTresorFragment(); } @Provides @ActivityScope
public EncryptTextFragment provideEncryptTextFragment() {
tresorit/ZeroKit-Android-SDK
adminapi/src/main/java/com/tresorit/zerokit/AdminApi.java
// Path: common/src/main/java/com/tresorit/zerokit/call/Call.java // public interface Call<T, S> extends CallAsync<T, S> { // Response<T, S> execute(); // } // // Path: common/src/main/java/com/tresorit/zerokit/call/CallBase.java // public abstract class CallBase<T, S> extends CallAsyncBase<T, S> implements Call<T, S> { // } // // Path: common/src/main/java/com/tresorit/zerokit/call/Callback.java // public interface Callback<T, S> { // // void onSuccess(T result); // // void onError(S e); // // } // // Path: common/src/main/java/com/tresorit/zerokit/call/Response.java // public class Response<T, S> { // // private T result; // private S error; // // public static <T, S> Response<T, S> fromValue(T value){ // Response<T, S> response = new Response<>(); // response.setResult(value); // return response; // } // // public static <T, S> Response<T, S> fromError(S error){ // Response<T, S> response = new Response<>(); // response.setError(error); // return response; // } // // public static <T, S> Response<T, S> from(T value, S error){ // Response<T, S> response = new Response<>(); // response.setResult(value); // response.setError(error); // return response; // } // // private Response(){} // // private void setError(S error) { // this.error = error; // } // // void setResult(T result) { // this.result = result; // } // // public boolean isError() { // return error != null; // } // // public T getResult() { // return result; // } // // public S getError() { // return error; // } // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiError.java // public class ResponseAdminApiError { // private String code; // private String message; // private ResponseExtensionException exception; // // public ResponseAdminApiError(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return String.format("code: %s, message: %s", code, message); // } // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiInitUserRegistration.java // public class ResponseAdminApiInitUserRegistration { // private String userId; // private String regSessionId; // // public String getUserId() { // return userId; // } // // public String getRegSessionId() { // return regSessionId; // } // // // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiLoginByCode.java // public class ResponseAdminApiLoginByCode { // private String userId; // // private String id; // // private String validUntil; // // public String getId() { // return id; // } // // } // // Path: common/src/main/java/com/tresorit/zerokit/util/Holder.java // public class Holder<T>{ // public T t; // }
import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; import android.support.test.espresso.IdlingResource; import com.google.gson.Gson; import com.tresorit.zerokit.call.Call; import com.tresorit.zerokit.call.CallBase; import com.tresorit.zerokit.call.Callback; import com.tresorit.zerokit.call.Response; import com.tresorit.zerokit.response.ResponseAdminApiError; import com.tresorit.zerokit.response.ResponseAdminApiInitUserRegistration; import com.tresorit.zerokit.response.ResponseAdminApiLoginByCode; import com.tresorit.zerokit.util.Holder; import com.zerokit.zerokit.BuildConfig; import org.json.JSONException; import java.io.EOFException; import java.io.IOException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicInteger; import okhttp3.Interceptor; import okhttp3.MediaType; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.ResponseBody; import okhttp3.logging.HttpLoggingInterceptor; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.http.Body; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; import retrofit2.http.GET; import retrofit2.http.Headers; import retrofit2.http.POST; import retrofit2.http.Query;
@SuppressWarnings("WeakerAccess") static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); @SuppressWarnings("WeakerAccess") final Executor executorBackground; @SuppressWarnings("WeakerAccess") @Nullable ZerokitCountingIdlingResource idlingResource; private static AdminApi instance; public static AdminApi init(@NonNull String host, String clientId) { instance = new AdminApi(host, clientId); return instance; } public static AdminApi getInstance() { return instance; } private AdminApi(String appbackendUrl, String clientId) { this.clientId = clientId; OkHttpClient.Builder builderHttpClient = new OkHttpClient.Builder(); HttpLoggingInterceptor interceptorLogging = new HttpLoggingInterceptor(); interceptorLogging.setLevel(BuildConfig.DEBUG ? HttpLoggingInterceptor.Level.BODY : HttpLoggingInterceptor.Level.NONE); Interceptor interceptorAuthorization = new Interceptor() { @Override
// Path: common/src/main/java/com/tresorit/zerokit/call/Call.java // public interface Call<T, S> extends CallAsync<T, S> { // Response<T, S> execute(); // } // // Path: common/src/main/java/com/tresorit/zerokit/call/CallBase.java // public abstract class CallBase<T, S> extends CallAsyncBase<T, S> implements Call<T, S> { // } // // Path: common/src/main/java/com/tresorit/zerokit/call/Callback.java // public interface Callback<T, S> { // // void onSuccess(T result); // // void onError(S e); // // } // // Path: common/src/main/java/com/tresorit/zerokit/call/Response.java // public class Response<T, S> { // // private T result; // private S error; // // public static <T, S> Response<T, S> fromValue(T value){ // Response<T, S> response = new Response<>(); // response.setResult(value); // return response; // } // // public static <T, S> Response<T, S> fromError(S error){ // Response<T, S> response = new Response<>(); // response.setError(error); // return response; // } // // public static <T, S> Response<T, S> from(T value, S error){ // Response<T, S> response = new Response<>(); // response.setResult(value); // response.setError(error); // return response; // } // // private Response(){} // // private void setError(S error) { // this.error = error; // } // // void setResult(T result) { // this.result = result; // } // // public boolean isError() { // return error != null; // } // // public T getResult() { // return result; // } // // public S getError() { // return error; // } // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiError.java // public class ResponseAdminApiError { // private String code; // private String message; // private ResponseExtensionException exception; // // public ResponseAdminApiError(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return String.format("code: %s, message: %s", code, message); // } // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiInitUserRegistration.java // public class ResponseAdminApiInitUserRegistration { // private String userId; // private String regSessionId; // // public String getUserId() { // return userId; // } // // public String getRegSessionId() { // return regSessionId; // } // // // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiLoginByCode.java // public class ResponseAdminApiLoginByCode { // private String userId; // // private String id; // // private String validUntil; // // public String getId() { // return id; // } // // } // // Path: common/src/main/java/com/tresorit/zerokit/util/Holder.java // public class Holder<T>{ // public T t; // } // Path: adminapi/src/main/java/com/tresorit/zerokit/AdminApi.java import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; import android.support.test.espresso.IdlingResource; import com.google.gson.Gson; import com.tresorit.zerokit.call.Call; import com.tresorit.zerokit.call.CallBase; import com.tresorit.zerokit.call.Callback; import com.tresorit.zerokit.call.Response; import com.tresorit.zerokit.response.ResponseAdminApiError; import com.tresorit.zerokit.response.ResponseAdminApiInitUserRegistration; import com.tresorit.zerokit.response.ResponseAdminApiLoginByCode; import com.tresorit.zerokit.util.Holder; import com.zerokit.zerokit.BuildConfig; import org.json.JSONException; import java.io.EOFException; import java.io.IOException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicInteger; import okhttp3.Interceptor; import okhttp3.MediaType; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.ResponseBody; import okhttp3.logging.HttpLoggingInterceptor; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.http.Body; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; import retrofit2.http.GET; import retrofit2.http.Headers; import retrofit2.http.POST; import retrofit2.http.Query; @SuppressWarnings("WeakerAccess") static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); @SuppressWarnings("WeakerAccess") final Executor executorBackground; @SuppressWarnings("WeakerAccess") @Nullable ZerokitCountingIdlingResource idlingResource; private static AdminApi instance; public static AdminApi init(@NonNull String host, String clientId) { instance = new AdminApi(host, clientId); return instance; } public static AdminApi getInstance() { return instance; } private AdminApi(String appbackendUrl, String clientId) { this.clientId = clientId; OkHttpClient.Builder builderHttpClient = new OkHttpClient.Builder(); HttpLoggingInterceptor interceptorLogging = new HttpLoggingInterceptor(); interceptorLogging.setLevel(BuildConfig.DEBUG ? HttpLoggingInterceptor.Level.BODY : HttpLoggingInterceptor.Level.NONE); Interceptor interceptorAuthorization = new Interceptor() { @Override
public okhttp3.Response intercept(Chain chain) throws IOException {
tresorit/ZeroKit-Android-SDK
adminapi/src/main/java/com/tresorit/zerokit/AdminApi.java
// Path: common/src/main/java/com/tresorit/zerokit/call/Call.java // public interface Call<T, S> extends CallAsync<T, S> { // Response<T, S> execute(); // } // // Path: common/src/main/java/com/tresorit/zerokit/call/CallBase.java // public abstract class CallBase<T, S> extends CallAsyncBase<T, S> implements Call<T, S> { // } // // Path: common/src/main/java/com/tresorit/zerokit/call/Callback.java // public interface Callback<T, S> { // // void onSuccess(T result); // // void onError(S e); // // } // // Path: common/src/main/java/com/tresorit/zerokit/call/Response.java // public class Response<T, S> { // // private T result; // private S error; // // public static <T, S> Response<T, S> fromValue(T value){ // Response<T, S> response = new Response<>(); // response.setResult(value); // return response; // } // // public static <T, S> Response<T, S> fromError(S error){ // Response<T, S> response = new Response<>(); // response.setError(error); // return response; // } // // public static <T, S> Response<T, S> from(T value, S error){ // Response<T, S> response = new Response<>(); // response.setResult(value); // response.setError(error); // return response; // } // // private Response(){} // // private void setError(S error) { // this.error = error; // } // // void setResult(T result) { // this.result = result; // } // // public boolean isError() { // return error != null; // } // // public T getResult() { // return result; // } // // public S getError() { // return error; // } // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiError.java // public class ResponseAdminApiError { // private String code; // private String message; // private ResponseExtensionException exception; // // public ResponseAdminApiError(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return String.format("code: %s, message: %s", code, message); // } // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiInitUserRegistration.java // public class ResponseAdminApiInitUserRegistration { // private String userId; // private String regSessionId; // // public String getUserId() { // return userId; // } // // public String getRegSessionId() { // return regSessionId; // } // // // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiLoginByCode.java // public class ResponseAdminApiLoginByCode { // private String userId; // // private String id; // // private String validUntil; // // public String getId() { // return id; // } // // } // // Path: common/src/main/java/com/tresorit/zerokit/util/Holder.java // public class Holder<T>{ // public T t; // }
import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; import android.support.test.espresso.IdlingResource; import com.google.gson.Gson; import com.tresorit.zerokit.call.Call; import com.tresorit.zerokit.call.CallBase; import com.tresorit.zerokit.call.Callback; import com.tresorit.zerokit.call.Response; import com.tresorit.zerokit.response.ResponseAdminApiError; import com.tresorit.zerokit.response.ResponseAdminApiInitUserRegistration; import com.tresorit.zerokit.response.ResponseAdminApiLoginByCode; import com.tresorit.zerokit.util.Holder; import com.zerokit.zerokit.BuildConfig; import org.json.JSONException; import java.io.EOFException; import java.io.IOException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicInteger; import okhttp3.Interceptor; import okhttp3.MediaType; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.ResponseBody; import okhttp3.logging.HttpLoggingInterceptor; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.http.Body; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; import retrofit2.http.GET; import retrofit2.http.Headers; import retrofit2.http.POST; import retrofit2.http.Query;
} public void setClientId(String clientId) { this.clientId = clientId; } public void clearClientId() { setClientId(null); } public void setToken(String token) { this.token = token; } public void clearToken() { setToken(null); } public String getToken() { return token; } private String getData(String data) { return getData(data, null); } private String getData(String data, String tresorId) { return new JSONObject().put("data", data).put("tresorId", tresorId).toString(); }
// Path: common/src/main/java/com/tresorit/zerokit/call/Call.java // public interface Call<T, S> extends CallAsync<T, S> { // Response<T, S> execute(); // } // // Path: common/src/main/java/com/tresorit/zerokit/call/CallBase.java // public abstract class CallBase<T, S> extends CallAsyncBase<T, S> implements Call<T, S> { // } // // Path: common/src/main/java/com/tresorit/zerokit/call/Callback.java // public interface Callback<T, S> { // // void onSuccess(T result); // // void onError(S e); // // } // // Path: common/src/main/java/com/tresorit/zerokit/call/Response.java // public class Response<T, S> { // // private T result; // private S error; // // public static <T, S> Response<T, S> fromValue(T value){ // Response<T, S> response = new Response<>(); // response.setResult(value); // return response; // } // // public static <T, S> Response<T, S> fromError(S error){ // Response<T, S> response = new Response<>(); // response.setError(error); // return response; // } // // public static <T, S> Response<T, S> from(T value, S error){ // Response<T, S> response = new Response<>(); // response.setResult(value); // response.setError(error); // return response; // } // // private Response(){} // // private void setError(S error) { // this.error = error; // } // // void setResult(T result) { // this.result = result; // } // // public boolean isError() { // return error != null; // } // // public T getResult() { // return result; // } // // public S getError() { // return error; // } // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiError.java // public class ResponseAdminApiError { // private String code; // private String message; // private ResponseExtensionException exception; // // public ResponseAdminApiError(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return String.format("code: %s, message: %s", code, message); // } // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiInitUserRegistration.java // public class ResponseAdminApiInitUserRegistration { // private String userId; // private String regSessionId; // // public String getUserId() { // return userId; // } // // public String getRegSessionId() { // return regSessionId; // } // // // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiLoginByCode.java // public class ResponseAdminApiLoginByCode { // private String userId; // // private String id; // // private String validUntil; // // public String getId() { // return id; // } // // } // // Path: common/src/main/java/com/tresorit/zerokit/util/Holder.java // public class Holder<T>{ // public T t; // } // Path: adminapi/src/main/java/com/tresorit/zerokit/AdminApi.java import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; import android.support.test.espresso.IdlingResource; import com.google.gson.Gson; import com.tresorit.zerokit.call.Call; import com.tresorit.zerokit.call.CallBase; import com.tresorit.zerokit.call.Callback; import com.tresorit.zerokit.call.Response; import com.tresorit.zerokit.response.ResponseAdminApiError; import com.tresorit.zerokit.response.ResponseAdminApiInitUserRegistration; import com.tresorit.zerokit.response.ResponseAdminApiLoginByCode; import com.tresorit.zerokit.util.Holder; import com.zerokit.zerokit.BuildConfig; import org.json.JSONException; import java.io.EOFException; import java.io.IOException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicInteger; import okhttp3.Interceptor; import okhttp3.MediaType; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.ResponseBody; import okhttp3.logging.HttpLoggingInterceptor; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.http.Body; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; import retrofit2.http.GET; import retrofit2.http.Headers; import retrofit2.http.POST; import retrofit2.http.Query; } public void setClientId(String clientId) { this.clientId = clientId; } public void clearClientId() { setClientId(null); } public void setToken(String token) { this.token = token; } public void clearToken() { setToken(null); } public String getToken() { return token; } private String getData(String data) { return getData(data, null); } private String getData(String data, String tresorId) { return new JSONObject().put("data", data).put("tresorId", tresorId).toString(); }
public Call<String, ResponseAdminApiError> getUserId(final String userName) {
tresorit/ZeroKit-Android-SDK
adminapi/src/main/java/com/tresorit/zerokit/AdminApi.java
// Path: common/src/main/java/com/tresorit/zerokit/call/Call.java // public interface Call<T, S> extends CallAsync<T, S> { // Response<T, S> execute(); // } // // Path: common/src/main/java/com/tresorit/zerokit/call/CallBase.java // public abstract class CallBase<T, S> extends CallAsyncBase<T, S> implements Call<T, S> { // } // // Path: common/src/main/java/com/tresorit/zerokit/call/Callback.java // public interface Callback<T, S> { // // void onSuccess(T result); // // void onError(S e); // // } // // Path: common/src/main/java/com/tresorit/zerokit/call/Response.java // public class Response<T, S> { // // private T result; // private S error; // // public static <T, S> Response<T, S> fromValue(T value){ // Response<T, S> response = new Response<>(); // response.setResult(value); // return response; // } // // public static <T, S> Response<T, S> fromError(S error){ // Response<T, S> response = new Response<>(); // response.setError(error); // return response; // } // // public static <T, S> Response<T, S> from(T value, S error){ // Response<T, S> response = new Response<>(); // response.setResult(value); // response.setError(error); // return response; // } // // private Response(){} // // private void setError(S error) { // this.error = error; // } // // void setResult(T result) { // this.result = result; // } // // public boolean isError() { // return error != null; // } // // public T getResult() { // return result; // } // // public S getError() { // return error; // } // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiError.java // public class ResponseAdminApiError { // private String code; // private String message; // private ResponseExtensionException exception; // // public ResponseAdminApiError(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return String.format("code: %s, message: %s", code, message); // } // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiInitUserRegistration.java // public class ResponseAdminApiInitUserRegistration { // private String userId; // private String regSessionId; // // public String getUserId() { // return userId; // } // // public String getRegSessionId() { // return regSessionId; // } // // // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiLoginByCode.java // public class ResponseAdminApiLoginByCode { // private String userId; // // private String id; // // private String validUntil; // // public String getId() { // return id; // } // // } // // Path: common/src/main/java/com/tresorit/zerokit/util/Holder.java // public class Holder<T>{ // public T t; // }
import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; import android.support.test.espresso.IdlingResource; import com.google.gson.Gson; import com.tresorit.zerokit.call.Call; import com.tresorit.zerokit.call.CallBase; import com.tresorit.zerokit.call.Callback; import com.tresorit.zerokit.call.Response; import com.tresorit.zerokit.response.ResponseAdminApiError; import com.tresorit.zerokit.response.ResponseAdminApiInitUserRegistration; import com.tresorit.zerokit.response.ResponseAdminApiLoginByCode; import com.tresorit.zerokit.util.Holder; import com.zerokit.zerokit.BuildConfig; import org.json.JSONException; import java.io.EOFException; import java.io.IOException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicInteger; import okhttp3.Interceptor; import okhttp3.MediaType; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.ResponseBody; import okhttp3.logging.HttpLoggingInterceptor; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.http.Body; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; import retrofit2.http.GET; import retrofit2.http.Headers; import retrofit2.http.POST; import retrofit2.http.Query;
} public void setClientId(String clientId) { this.clientId = clientId; } public void clearClientId() { setClientId(null); } public void setToken(String token) { this.token = token; } public void clearToken() { setToken(null); } public String getToken() { return token; } private String getData(String data) { return getData(data, null); } private String getData(String data, String tresorId) { return new JSONObject().put("data", data).put("tresorId", tresorId).toString(); }
// Path: common/src/main/java/com/tresorit/zerokit/call/Call.java // public interface Call<T, S> extends CallAsync<T, S> { // Response<T, S> execute(); // } // // Path: common/src/main/java/com/tresorit/zerokit/call/CallBase.java // public abstract class CallBase<T, S> extends CallAsyncBase<T, S> implements Call<T, S> { // } // // Path: common/src/main/java/com/tresorit/zerokit/call/Callback.java // public interface Callback<T, S> { // // void onSuccess(T result); // // void onError(S e); // // } // // Path: common/src/main/java/com/tresorit/zerokit/call/Response.java // public class Response<T, S> { // // private T result; // private S error; // // public static <T, S> Response<T, S> fromValue(T value){ // Response<T, S> response = new Response<>(); // response.setResult(value); // return response; // } // // public static <T, S> Response<T, S> fromError(S error){ // Response<T, S> response = new Response<>(); // response.setError(error); // return response; // } // // public static <T, S> Response<T, S> from(T value, S error){ // Response<T, S> response = new Response<>(); // response.setResult(value); // response.setError(error); // return response; // } // // private Response(){} // // private void setError(S error) { // this.error = error; // } // // void setResult(T result) { // this.result = result; // } // // public boolean isError() { // return error != null; // } // // public T getResult() { // return result; // } // // public S getError() { // return error; // } // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiError.java // public class ResponseAdminApiError { // private String code; // private String message; // private ResponseExtensionException exception; // // public ResponseAdminApiError(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return String.format("code: %s, message: %s", code, message); // } // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiInitUserRegistration.java // public class ResponseAdminApiInitUserRegistration { // private String userId; // private String regSessionId; // // public String getUserId() { // return userId; // } // // public String getRegSessionId() { // return regSessionId; // } // // // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiLoginByCode.java // public class ResponseAdminApiLoginByCode { // private String userId; // // private String id; // // private String validUntil; // // public String getId() { // return id; // } // // } // // Path: common/src/main/java/com/tresorit/zerokit/util/Holder.java // public class Holder<T>{ // public T t; // } // Path: adminapi/src/main/java/com/tresorit/zerokit/AdminApi.java import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; import android.support.test.espresso.IdlingResource; import com.google.gson.Gson; import com.tresorit.zerokit.call.Call; import com.tresorit.zerokit.call.CallBase; import com.tresorit.zerokit.call.Callback; import com.tresorit.zerokit.call.Response; import com.tresorit.zerokit.response.ResponseAdminApiError; import com.tresorit.zerokit.response.ResponseAdminApiInitUserRegistration; import com.tresorit.zerokit.response.ResponseAdminApiLoginByCode; import com.tresorit.zerokit.util.Holder; import com.zerokit.zerokit.BuildConfig; import org.json.JSONException; import java.io.EOFException; import java.io.IOException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicInteger; import okhttp3.Interceptor; import okhttp3.MediaType; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.ResponseBody; import okhttp3.logging.HttpLoggingInterceptor; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.http.Body; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; import retrofit2.http.GET; import retrofit2.http.Headers; import retrofit2.http.POST; import retrofit2.http.Query; } public void setClientId(String clientId) { this.clientId = clientId; } public void clearClientId() { setClientId(null); } public void setToken(String token) { this.token = token; } public void clearToken() { setToken(null); } public String getToken() { return token; } private String getData(String data) { return getData(data, null); } private String getData(String data, String tresorId) { return new JSONObject().put("data", data).put("tresorId", tresorId).toString(); }
public Call<String, ResponseAdminApiError> getUserId(final String userName) {
tresorit/ZeroKit-Android-SDK
adminapi/src/main/java/com/tresorit/zerokit/AdminApi.java
// Path: common/src/main/java/com/tresorit/zerokit/call/Call.java // public interface Call<T, S> extends CallAsync<T, S> { // Response<T, S> execute(); // } // // Path: common/src/main/java/com/tresorit/zerokit/call/CallBase.java // public abstract class CallBase<T, S> extends CallAsyncBase<T, S> implements Call<T, S> { // } // // Path: common/src/main/java/com/tresorit/zerokit/call/Callback.java // public interface Callback<T, S> { // // void onSuccess(T result); // // void onError(S e); // // } // // Path: common/src/main/java/com/tresorit/zerokit/call/Response.java // public class Response<T, S> { // // private T result; // private S error; // // public static <T, S> Response<T, S> fromValue(T value){ // Response<T, S> response = new Response<>(); // response.setResult(value); // return response; // } // // public static <T, S> Response<T, S> fromError(S error){ // Response<T, S> response = new Response<>(); // response.setError(error); // return response; // } // // public static <T, S> Response<T, S> from(T value, S error){ // Response<T, S> response = new Response<>(); // response.setResult(value); // response.setError(error); // return response; // } // // private Response(){} // // private void setError(S error) { // this.error = error; // } // // void setResult(T result) { // this.result = result; // } // // public boolean isError() { // return error != null; // } // // public T getResult() { // return result; // } // // public S getError() { // return error; // } // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiError.java // public class ResponseAdminApiError { // private String code; // private String message; // private ResponseExtensionException exception; // // public ResponseAdminApiError(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return String.format("code: %s, message: %s", code, message); // } // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiInitUserRegistration.java // public class ResponseAdminApiInitUserRegistration { // private String userId; // private String regSessionId; // // public String getUserId() { // return userId; // } // // public String getRegSessionId() { // return regSessionId; // } // // // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiLoginByCode.java // public class ResponseAdminApiLoginByCode { // private String userId; // // private String id; // // private String validUntil; // // public String getId() { // return id; // } // // } // // Path: common/src/main/java/com/tresorit/zerokit/util/Holder.java // public class Holder<T>{ // public T t; // }
import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; import android.support.test.espresso.IdlingResource; import com.google.gson.Gson; import com.tresorit.zerokit.call.Call; import com.tresorit.zerokit.call.CallBase; import com.tresorit.zerokit.call.Callback; import com.tresorit.zerokit.call.Response; import com.tresorit.zerokit.response.ResponseAdminApiError; import com.tresorit.zerokit.response.ResponseAdminApiInitUserRegistration; import com.tresorit.zerokit.response.ResponseAdminApiLoginByCode; import com.tresorit.zerokit.util.Holder; import com.zerokit.zerokit.BuildConfig; import org.json.JSONException; import java.io.EOFException; import java.io.IOException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicInteger; import okhttp3.Interceptor; import okhttp3.MediaType; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.ResponseBody; import okhttp3.logging.HttpLoggingInterceptor; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.http.Body; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; import retrofit2.http.GET; import retrofit2.http.Headers; import retrofit2.http.POST; import retrofit2.http.Query;
} public void clearClientId() { setClientId(null); } public void setToken(String token) { this.token = token; } public void clearToken() { setToken(null); } public String getToken() { return token; } private String getData(String data) { return getData(data, null); } private String getData(String data, String tresorId) { return new JSONObject().put("data", data).put("tresorId", tresorId).toString(); } public Call<String, ResponseAdminApiError> getUserId(final String userName) { return new CallRetrofit<>(adminApiService.getUserId(userName)); }
// Path: common/src/main/java/com/tresorit/zerokit/call/Call.java // public interface Call<T, S> extends CallAsync<T, S> { // Response<T, S> execute(); // } // // Path: common/src/main/java/com/tresorit/zerokit/call/CallBase.java // public abstract class CallBase<T, S> extends CallAsyncBase<T, S> implements Call<T, S> { // } // // Path: common/src/main/java/com/tresorit/zerokit/call/Callback.java // public interface Callback<T, S> { // // void onSuccess(T result); // // void onError(S e); // // } // // Path: common/src/main/java/com/tresorit/zerokit/call/Response.java // public class Response<T, S> { // // private T result; // private S error; // // public static <T, S> Response<T, S> fromValue(T value){ // Response<T, S> response = new Response<>(); // response.setResult(value); // return response; // } // // public static <T, S> Response<T, S> fromError(S error){ // Response<T, S> response = new Response<>(); // response.setError(error); // return response; // } // // public static <T, S> Response<T, S> from(T value, S error){ // Response<T, S> response = new Response<>(); // response.setResult(value); // response.setError(error); // return response; // } // // private Response(){} // // private void setError(S error) { // this.error = error; // } // // void setResult(T result) { // this.result = result; // } // // public boolean isError() { // return error != null; // } // // public T getResult() { // return result; // } // // public S getError() { // return error; // } // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiError.java // public class ResponseAdminApiError { // private String code; // private String message; // private ResponseExtensionException exception; // // public ResponseAdminApiError(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return String.format("code: %s, message: %s", code, message); // } // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiInitUserRegistration.java // public class ResponseAdminApiInitUserRegistration { // private String userId; // private String regSessionId; // // public String getUserId() { // return userId; // } // // public String getRegSessionId() { // return regSessionId; // } // // // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiLoginByCode.java // public class ResponseAdminApiLoginByCode { // private String userId; // // private String id; // // private String validUntil; // // public String getId() { // return id; // } // // } // // Path: common/src/main/java/com/tresorit/zerokit/util/Holder.java // public class Holder<T>{ // public T t; // } // Path: adminapi/src/main/java/com/tresorit/zerokit/AdminApi.java import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; import android.support.test.espresso.IdlingResource; import com.google.gson.Gson; import com.tresorit.zerokit.call.Call; import com.tresorit.zerokit.call.CallBase; import com.tresorit.zerokit.call.Callback; import com.tresorit.zerokit.call.Response; import com.tresorit.zerokit.response.ResponseAdminApiError; import com.tresorit.zerokit.response.ResponseAdminApiInitUserRegistration; import com.tresorit.zerokit.response.ResponseAdminApiLoginByCode; import com.tresorit.zerokit.util.Holder; import com.zerokit.zerokit.BuildConfig; import org.json.JSONException; import java.io.EOFException; import java.io.IOException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicInteger; import okhttp3.Interceptor; import okhttp3.MediaType; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.ResponseBody; import okhttp3.logging.HttpLoggingInterceptor; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.http.Body; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; import retrofit2.http.GET; import retrofit2.http.Headers; import retrofit2.http.POST; import retrofit2.http.Query; } public void clearClientId() { setClientId(null); } public void setToken(String token) { this.token = token; } public void clearToken() { setToken(null); } public String getToken() { return token; } private String getData(String data) { return getData(data, null); } private String getData(String data, String tresorId) { return new JSONObject().put("data", data).put("tresorId", tresorId).toString(); } public Call<String, ResponseAdminApiError> getUserId(final String userName) { return new CallRetrofit<>(adminApiService.getUserId(userName)); }
public Call<ResponseAdminApiInitUserRegistration, ResponseAdminApiError> initReg(final String userName, final String profileData) {
tresorit/ZeroKit-Android-SDK
adminapi/src/main/java/com/tresorit/zerokit/AdminApi.java
// Path: common/src/main/java/com/tresorit/zerokit/call/Call.java // public interface Call<T, S> extends CallAsync<T, S> { // Response<T, S> execute(); // } // // Path: common/src/main/java/com/tresorit/zerokit/call/CallBase.java // public abstract class CallBase<T, S> extends CallAsyncBase<T, S> implements Call<T, S> { // } // // Path: common/src/main/java/com/tresorit/zerokit/call/Callback.java // public interface Callback<T, S> { // // void onSuccess(T result); // // void onError(S e); // // } // // Path: common/src/main/java/com/tresorit/zerokit/call/Response.java // public class Response<T, S> { // // private T result; // private S error; // // public static <T, S> Response<T, S> fromValue(T value){ // Response<T, S> response = new Response<>(); // response.setResult(value); // return response; // } // // public static <T, S> Response<T, S> fromError(S error){ // Response<T, S> response = new Response<>(); // response.setError(error); // return response; // } // // public static <T, S> Response<T, S> from(T value, S error){ // Response<T, S> response = new Response<>(); // response.setResult(value); // response.setError(error); // return response; // } // // private Response(){} // // private void setError(S error) { // this.error = error; // } // // void setResult(T result) { // this.result = result; // } // // public boolean isError() { // return error != null; // } // // public T getResult() { // return result; // } // // public S getError() { // return error; // } // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiError.java // public class ResponseAdminApiError { // private String code; // private String message; // private ResponseExtensionException exception; // // public ResponseAdminApiError(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return String.format("code: %s, message: %s", code, message); // } // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiInitUserRegistration.java // public class ResponseAdminApiInitUserRegistration { // private String userId; // private String regSessionId; // // public String getUserId() { // return userId; // } // // public String getRegSessionId() { // return regSessionId; // } // // // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiLoginByCode.java // public class ResponseAdminApiLoginByCode { // private String userId; // // private String id; // // private String validUntil; // // public String getId() { // return id; // } // // } // // Path: common/src/main/java/com/tresorit/zerokit/util/Holder.java // public class Holder<T>{ // public T t; // }
import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; import android.support.test.espresso.IdlingResource; import com.google.gson.Gson; import com.tresorit.zerokit.call.Call; import com.tresorit.zerokit.call.CallBase; import com.tresorit.zerokit.call.Callback; import com.tresorit.zerokit.call.Response; import com.tresorit.zerokit.response.ResponseAdminApiError; import com.tresorit.zerokit.response.ResponseAdminApiInitUserRegistration; import com.tresorit.zerokit.response.ResponseAdminApiLoginByCode; import com.tresorit.zerokit.util.Holder; import com.zerokit.zerokit.BuildConfig; import org.json.JSONException; import java.io.EOFException; import java.io.IOException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicInteger; import okhttp3.Interceptor; import okhttp3.MediaType; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.ResponseBody; import okhttp3.logging.HttpLoggingInterceptor; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.http.Body; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; import retrofit2.http.GET; import retrofit2.http.Headers; import retrofit2.http.POST; import retrofit2.http.Query;
return new CallRetrofit<>(adminApiService.storeData(id, RequestBody.create(JSON, getData(data, tresorId)))); } @SuppressWarnings("WeakerAccess") public Call<String, ResponseAdminApiError> fetchData(final String id) { return new CallRetrofit<>(adminApiService.fetchData(id)); } public Call<Void, ResponseAdminApiError> acceptedInvitationLink(final String operationId) { return new CallRetrofit<>(adminApiService.acceptedInvitationLink(operationId)); } public Call<Void, ResponseAdminApiError> createdInvitationLink(final String operationId) { return new CallRetrofit<>(adminApiService.createdInvitationLink(operationId)); } public Call<Void, ResponseAdminApiError> revokedInvitationLink(final String operationId) { return new CallRetrofit<>(adminApiService.revokedInvitationLink(operationId)); } private class CallRetrofit<T> extends CallBase<T, ResponseAdminApiError> { final retrofit2.Call<T> call; CallRetrofit(retrofit2.Call<T> call) { this.call = call; } @Override
// Path: common/src/main/java/com/tresorit/zerokit/call/Call.java // public interface Call<T, S> extends CallAsync<T, S> { // Response<T, S> execute(); // } // // Path: common/src/main/java/com/tresorit/zerokit/call/CallBase.java // public abstract class CallBase<T, S> extends CallAsyncBase<T, S> implements Call<T, S> { // } // // Path: common/src/main/java/com/tresorit/zerokit/call/Callback.java // public interface Callback<T, S> { // // void onSuccess(T result); // // void onError(S e); // // } // // Path: common/src/main/java/com/tresorit/zerokit/call/Response.java // public class Response<T, S> { // // private T result; // private S error; // // public static <T, S> Response<T, S> fromValue(T value){ // Response<T, S> response = new Response<>(); // response.setResult(value); // return response; // } // // public static <T, S> Response<T, S> fromError(S error){ // Response<T, S> response = new Response<>(); // response.setError(error); // return response; // } // // public static <T, S> Response<T, S> from(T value, S error){ // Response<T, S> response = new Response<>(); // response.setResult(value); // response.setError(error); // return response; // } // // private Response(){} // // private void setError(S error) { // this.error = error; // } // // void setResult(T result) { // this.result = result; // } // // public boolean isError() { // return error != null; // } // // public T getResult() { // return result; // } // // public S getError() { // return error; // } // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiError.java // public class ResponseAdminApiError { // private String code; // private String message; // private ResponseExtensionException exception; // // public ResponseAdminApiError(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return String.format("code: %s, message: %s", code, message); // } // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiInitUserRegistration.java // public class ResponseAdminApiInitUserRegistration { // private String userId; // private String regSessionId; // // public String getUserId() { // return userId; // } // // public String getRegSessionId() { // return regSessionId; // } // // // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiLoginByCode.java // public class ResponseAdminApiLoginByCode { // private String userId; // // private String id; // // private String validUntil; // // public String getId() { // return id; // } // // } // // Path: common/src/main/java/com/tresorit/zerokit/util/Holder.java // public class Holder<T>{ // public T t; // } // Path: adminapi/src/main/java/com/tresorit/zerokit/AdminApi.java import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; import android.support.test.espresso.IdlingResource; import com.google.gson.Gson; import com.tresorit.zerokit.call.Call; import com.tresorit.zerokit.call.CallBase; import com.tresorit.zerokit.call.Callback; import com.tresorit.zerokit.call.Response; import com.tresorit.zerokit.response.ResponseAdminApiError; import com.tresorit.zerokit.response.ResponseAdminApiInitUserRegistration; import com.tresorit.zerokit.response.ResponseAdminApiLoginByCode; import com.tresorit.zerokit.util.Holder; import com.zerokit.zerokit.BuildConfig; import org.json.JSONException; import java.io.EOFException; import java.io.IOException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicInteger; import okhttp3.Interceptor; import okhttp3.MediaType; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.ResponseBody; import okhttp3.logging.HttpLoggingInterceptor; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.http.Body; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; import retrofit2.http.GET; import retrofit2.http.Headers; import retrofit2.http.POST; import retrofit2.http.Query; return new CallRetrofit<>(adminApiService.storeData(id, RequestBody.create(JSON, getData(data, tresorId)))); } @SuppressWarnings("WeakerAccess") public Call<String, ResponseAdminApiError> fetchData(final String id) { return new CallRetrofit<>(adminApiService.fetchData(id)); } public Call<Void, ResponseAdminApiError> acceptedInvitationLink(final String operationId) { return new CallRetrofit<>(adminApiService.acceptedInvitationLink(operationId)); } public Call<Void, ResponseAdminApiError> createdInvitationLink(final String operationId) { return new CallRetrofit<>(adminApiService.createdInvitationLink(operationId)); } public Call<Void, ResponseAdminApiError> revokedInvitationLink(final String operationId) { return new CallRetrofit<>(adminApiService.revokedInvitationLink(operationId)); } private class CallRetrofit<T> extends CallBase<T, ResponseAdminApiError> { final retrofit2.Call<T> call; CallRetrofit(retrofit2.Call<T> call) { this.call = call; } @Override
public void enqueue(Callback<? super T, ? super ResponseAdminApiError> callback) {
tresorit/ZeroKit-Android-SDK
adminapi/src/main/java/com/tresorit/zerokit/AdminApi.java
// Path: common/src/main/java/com/tresorit/zerokit/call/Call.java // public interface Call<T, S> extends CallAsync<T, S> { // Response<T, S> execute(); // } // // Path: common/src/main/java/com/tresorit/zerokit/call/CallBase.java // public abstract class CallBase<T, S> extends CallAsyncBase<T, S> implements Call<T, S> { // } // // Path: common/src/main/java/com/tresorit/zerokit/call/Callback.java // public interface Callback<T, S> { // // void onSuccess(T result); // // void onError(S e); // // } // // Path: common/src/main/java/com/tresorit/zerokit/call/Response.java // public class Response<T, S> { // // private T result; // private S error; // // public static <T, S> Response<T, S> fromValue(T value){ // Response<T, S> response = new Response<>(); // response.setResult(value); // return response; // } // // public static <T, S> Response<T, S> fromError(S error){ // Response<T, S> response = new Response<>(); // response.setError(error); // return response; // } // // public static <T, S> Response<T, S> from(T value, S error){ // Response<T, S> response = new Response<>(); // response.setResult(value); // response.setError(error); // return response; // } // // private Response(){} // // private void setError(S error) { // this.error = error; // } // // void setResult(T result) { // this.result = result; // } // // public boolean isError() { // return error != null; // } // // public T getResult() { // return result; // } // // public S getError() { // return error; // } // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiError.java // public class ResponseAdminApiError { // private String code; // private String message; // private ResponseExtensionException exception; // // public ResponseAdminApiError(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return String.format("code: %s, message: %s", code, message); // } // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiInitUserRegistration.java // public class ResponseAdminApiInitUserRegistration { // private String userId; // private String regSessionId; // // public String getUserId() { // return userId; // } // // public String getRegSessionId() { // return regSessionId; // } // // // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiLoginByCode.java // public class ResponseAdminApiLoginByCode { // private String userId; // // private String id; // // private String validUntil; // // public String getId() { // return id; // } // // } // // Path: common/src/main/java/com/tresorit/zerokit/util/Holder.java // public class Holder<T>{ // public T t; // }
import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; import android.support.test.espresso.IdlingResource; import com.google.gson.Gson; import com.tresorit.zerokit.call.Call; import com.tresorit.zerokit.call.CallBase; import com.tresorit.zerokit.call.Callback; import com.tresorit.zerokit.call.Response; import com.tresorit.zerokit.response.ResponseAdminApiError; import com.tresorit.zerokit.response.ResponseAdminApiInitUserRegistration; import com.tresorit.zerokit.response.ResponseAdminApiLoginByCode; import com.tresorit.zerokit.util.Holder; import com.zerokit.zerokit.BuildConfig; import org.json.JSONException; import java.io.EOFException; import java.io.IOException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicInteger; import okhttp3.Interceptor; import okhttp3.MediaType; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.ResponseBody; import okhttp3.logging.HttpLoggingInterceptor; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.http.Body; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; import retrofit2.http.GET; import retrofit2.http.Headers; import retrofit2.http.POST; import retrofit2.http.Query;
public Call<Void, ResponseAdminApiError> acceptedInvitationLink(final String operationId) { return new CallRetrofit<>(adminApiService.acceptedInvitationLink(operationId)); } public Call<Void, ResponseAdminApiError> createdInvitationLink(final String operationId) { return new CallRetrofit<>(adminApiService.createdInvitationLink(operationId)); } public Call<Void, ResponseAdminApiError> revokedInvitationLink(final String operationId) { return new CallRetrofit<>(adminApiService.revokedInvitationLink(operationId)); } private class CallRetrofit<T> extends CallBase<T, ResponseAdminApiError> { final retrofit2.Call<T> call; CallRetrofit(retrofit2.Call<T> call) { this.call = call; } @Override public void enqueue(Callback<? super T, ? super ResponseAdminApiError> callback) { incrementIdlingResource(); call.enqueue(new CallbackRetrofit<>(callback)); } @Override public Response<T, ResponseAdminApiError> execute() { incrementIdlingResource();
// Path: common/src/main/java/com/tresorit/zerokit/call/Call.java // public interface Call<T, S> extends CallAsync<T, S> { // Response<T, S> execute(); // } // // Path: common/src/main/java/com/tresorit/zerokit/call/CallBase.java // public abstract class CallBase<T, S> extends CallAsyncBase<T, S> implements Call<T, S> { // } // // Path: common/src/main/java/com/tresorit/zerokit/call/Callback.java // public interface Callback<T, S> { // // void onSuccess(T result); // // void onError(S e); // // } // // Path: common/src/main/java/com/tresorit/zerokit/call/Response.java // public class Response<T, S> { // // private T result; // private S error; // // public static <T, S> Response<T, S> fromValue(T value){ // Response<T, S> response = new Response<>(); // response.setResult(value); // return response; // } // // public static <T, S> Response<T, S> fromError(S error){ // Response<T, S> response = new Response<>(); // response.setError(error); // return response; // } // // public static <T, S> Response<T, S> from(T value, S error){ // Response<T, S> response = new Response<>(); // response.setResult(value); // response.setError(error); // return response; // } // // private Response(){} // // private void setError(S error) { // this.error = error; // } // // void setResult(T result) { // this.result = result; // } // // public boolean isError() { // return error != null; // } // // public T getResult() { // return result; // } // // public S getError() { // return error; // } // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiError.java // public class ResponseAdminApiError { // private String code; // private String message; // private ResponseExtensionException exception; // // public ResponseAdminApiError(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // // @Override // public String toString() { // return String.format("code: %s, message: %s", code, message); // } // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiInitUserRegistration.java // public class ResponseAdminApiInitUserRegistration { // private String userId; // private String regSessionId; // // public String getUserId() { // return userId; // } // // public String getRegSessionId() { // return regSessionId; // } // // // } // // Path: adminapi/src/main/java/com/tresorit/zerokit/response/ResponseAdminApiLoginByCode.java // public class ResponseAdminApiLoginByCode { // private String userId; // // private String id; // // private String validUntil; // // public String getId() { // return id; // } // // } // // Path: common/src/main/java/com/tresorit/zerokit/util/Holder.java // public class Holder<T>{ // public T t; // } // Path: adminapi/src/main/java/com/tresorit/zerokit/AdminApi.java import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; import android.support.test.espresso.IdlingResource; import com.google.gson.Gson; import com.tresorit.zerokit.call.Call; import com.tresorit.zerokit.call.CallBase; import com.tresorit.zerokit.call.Callback; import com.tresorit.zerokit.call.Response; import com.tresorit.zerokit.response.ResponseAdminApiError; import com.tresorit.zerokit.response.ResponseAdminApiInitUserRegistration; import com.tresorit.zerokit.response.ResponseAdminApiLoginByCode; import com.tresorit.zerokit.util.Holder; import com.zerokit.zerokit.BuildConfig; import org.json.JSONException; import java.io.EOFException; import java.io.IOException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicInteger; import okhttp3.Interceptor; import okhttp3.MediaType; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.ResponseBody; import okhttp3.logging.HttpLoggingInterceptor; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.http.Body; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; import retrofit2.http.GET; import retrofit2.http.Headers; import retrofit2.http.POST; import retrofit2.http.Query; public Call<Void, ResponseAdminApiError> acceptedInvitationLink(final String operationId) { return new CallRetrofit<>(adminApiService.acceptedInvitationLink(operationId)); } public Call<Void, ResponseAdminApiError> createdInvitationLink(final String operationId) { return new CallRetrofit<>(adminApiService.createdInvitationLink(operationId)); } public Call<Void, ResponseAdminApiError> revokedInvitationLink(final String operationId) { return new CallRetrofit<>(adminApiService.revokedInvitationLink(operationId)); } private class CallRetrofit<T> extends CallBase<T, ResponseAdminApiError> { final retrofit2.Call<T> call; CallRetrofit(retrofit2.Call<T> call) { this.call = call; } @Override public void enqueue(Callback<? super T, ? super ResponseAdminApiError> callback) { incrementIdlingResource(); call.enqueue(new CallbackRetrofit<>(callback)); } @Override public Response<T, ResponseAdminApiError> execute() { incrementIdlingResource();
final Holder<Response<T, ResponseAdminApiError>> result = new Holder<>();
OpenIndex/RemoteSupportTool
Customer/src/main/java/de/openindex/support/customer/utils/MacUtils.java
// Path: Customer/src/main/java/de/openindex/support/customer/utils/mac/CoreFoundation.java // @SuppressWarnings("unused") // public interface CoreFoundation extends Library { // String JNA_LIBRARY_NAME = "CoreFoundation"; // // /** // * Releases a Core Foundation object. // * // * @param cf A CFType object to release. This value must not be NULL. // * @see <a href="https://developer.apple.com/documentation/corefoundation/1521153-cfrelease">CFRelease</a> // */ // void CFRelease(CFTypeRef cf); // // /** // * An untyped "generic" reference to any Core Foundation object. // * // * @see <a href="https://developer.apple.com/documentation/corefoundation/cftyperef">CFTypeRef</a> // */ // class CFTypeRef extends Structure { // } // } // // Path: Customer/src/main/java/de/openindex/support/customer/utils/mac/CoreGraphics.java // @SuppressWarnings("unused") // public interface CoreGraphics extends Library { // String JNA_LIBRARY_NAME = "CoreGraphics"; // // /** // * Returns a new Quartz keyboard event. // * // * @param source An event source taken from another event, or NULL. // * @param virtualKey The virtual key code for the event. // * @param keyDown Pass true to specify that the key position is down. To specify that the key position is up, pass false. This value is used to determine the type of the keyboard event // * @return A new keyboard event, or NULL if the event could not be created. When you no longer need the event, you should release it using the function CFRelease. // * @see <a href="https://developer.apple.com/documentation/coregraphics/1456564-cgeventcreatekeyboardevent">CGEventCreateKeyboardEvent</a> // */ // CGEventRef CGEventCreateKeyboardEvent(CGEventSourceRef source, char virtualKey, boolean keyDown); // // /** // * Sets the Unicode string associated with a Quartz keyboard event. // * // * @param event The keyboard event to access. // * @param stringLength The length of the array you provide in the unicodeString parameter. // * @param unicodeString An array that contains the new Unicode string associated with the specified event. // * @see <a href="https://developer.apple.com/documentation/coregraphics/1456028-cgeventkeyboardsetunicodestring">CGEventKeyboardSetUnicodeString</a> // */ // void CGEventKeyboardSetUnicodeString(CGEventRef event, int stringLength, char[] unicodeString); // //void CGEventKeyboardSetUnicodeString(CGEventRef event, int stringLength, String unicodeString); // // /** // * Posts a Quartz event into the event stream at a specified location. // * // * @param tap The location at which to post the event. Pass one of the constants listed in {@link CGEventTapLocation}. // * @param event The event to post. // * @see <a href="https://developer.apple.com/documentation/coregraphics/1456527-cgeventpost">CGEventPost</a> // */ // void CGEventPost(int tap, CGEventRef event); // // /** // * Defines an opaque type that represents a low-level hardware event. // * // * @see <a href="https://developer.apple.com/documentation/coregraphics/cgeventref">CGEventRef</a> // */ // @Structure.FieldOrder({"CFHashCode", "CFTypeID", "CFTypeRef"}) // class CGEventRef extends CoreFoundation.CFTypeRef { // public NativeLong CFHashCode; // public NativeLong CFTypeID; // public Pointer CFTypeRef; // } // // /** // * Defines an opaque type that represents the source of a Quartz event. // * // * @see <a href="https://developer.apple.com/documentation/coregraphics/cgeventsourceref">CGEventSourceRef</a> // */ // class CGEventSourceRef extends CoreFoundation.CFTypeRef { // // } // // /** // * Constants that specify possible tapping points for events. // * // * @see <a href="https://developer.apple.com/documentation/coregraphics/cgeventtaplocation">CGEventTapLocation</a> // */ // interface CGEventTapLocation { // /** // * Specifies that an event tap is placed at the point where HID system events enter the window server. // */ // int kCGHIDEventTap = 0; // // /** // * Specifies that an event tap is placed at the point where HID system and remote control events enter a login session. // */ // int kCGSessionEventTap = 1; // // /** // * Specifies that an event tap is placed at the point where session events have been annotated to flow to an application. // */ // int kCGAnnotatedSessionEventTap = 2; // } // }
import com.sun.jna.Native; import de.openindex.support.customer.utils.mac.CoreFoundation; import de.openindex.support.customer.utils.mac.CoreGraphics; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
/* * Copyright 2015-2021 OpenIndex.de. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.openindex.support.customer.utils; /** * MacOS specific functions. * * @author Andreas Rudolph */ public class MacUtils { @SuppressWarnings("unused") private final static Logger LOGGER = LoggerFactory.getLogger(MacUtils.class);
// Path: Customer/src/main/java/de/openindex/support/customer/utils/mac/CoreFoundation.java // @SuppressWarnings("unused") // public interface CoreFoundation extends Library { // String JNA_LIBRARY_NAME = "CoreFoundation"; // // /** // * Releases a Core Foundation object. // * // * @param cf A CFType object to release. This value must not be NULL. // * @see <a href="https://developer.apple.com/documentation/corefoundation/1521153-cfrelease">CFRelease</a> // */ // void CFRelease(CFTypeRef cf); // // /** // * An untyped "generic" reference to any Core Foundation object. // * // * @see <a href="https://developer.apple.com/documentation/corefoundation/cftyperef">CFTypeRef</a> // */ // class CFTypeRef extends Structure { // } // } // // Path: Customer/src/main/java/de/openindex/support/customer/utils/mac/CoreGraphics.java // @SuppressWarnings("unused") // public interface CoreGraphics extends Library { // String JNA_LIBRARY_NAME = "CoreGraphics"; // // /** // * Returns a new Quartz keyboard event. // * // * @param source An event source taken from another event, or NULL. // * @param virtualKey The virtual key code for the event. // * @param keyDown Pass true to specify that the key position is down. To specify that the key position is up, pass false. This value is used to determine the type of the keyboard event // * @return A new keyboard event, or NULL if the event could not be created. When you no longer need the event, you should release it using the function CFRelease. // * @see <a href="https://developer.apple.com/documentation/coregraphics/1456564-cgeventcreatekeyboardevent">CGEventCreateKeyboardEvent</a> // */ // CGEventRef CGEventCreateKeyboardEvent(CGEventSourceRef source, char virtualKey, boolean keyDown); // // /** // * Sets the Unicode string associated with a Quartz keyboard event. // * // * @param event The keyboard event to access. // * @param stringLength The length of the array you provide in the unicodeString parameter. // * @param unicodeString An array that contains the new Unicode string associated with the specified event. // * @see <a href="https://developer.apple.com/documentation/coregraphics/1456028-cgeventkeyboardsetunicodestring">CGEventKeyboardSetUnicodeString</a> // */ // void CGEventKeyboardSetUnicodeString(CGEventRef event, int stringLength, char[] unicodeString); // //void CGEventKeyboardSetUnicodeString(CGEventRef event, int stringLength, String unicodeString); // // /** // * Posts a Quartz event into the event stream at a specified location. // * // * @param tap The location at which to post the event. Pass one of the constants listed in {@link CGEventTapLocation}. // * @param event The event to post. // * @see <a href="https://developer.apple.com/documentation/coregraphics/1456527-cgeventpost">CGEventPost</a> // */ // void CGEventPost(int tap, CGEventRef event); // // /** // * Defines an opaque type that represents a low-level hardware event. // * // * @see <a href="https://developer.apple.com/documentation/coregraphics/cgeventref">CGEventRef</a> // */ // @Structure.FieldOrder({"CFHashCode", "CFTypeID", "CFTypeRef"}) // class CGEventRef extends CoreFoundation.CFTypeRef { // public NativeLong CFHashCode; // public NativeLong CFTypeID; // public Pointer CFTypeRef; // } // // /** // * Defines an opaque type that represents the source of a Quartz event. // * // * @see <a href="https://developer.apple.com/documentation/coregraphics/cgeventsourceref">CGEventSourceRef</a> // */ // class CGEventSourceRef extends CoreFoundation.CFTypeRef { // // } // // /** // * Constants that specify possible tapping points for events. // * // * @see <a href="https://developer.apple.com/documentation/coregraphics/cgeventtaplocation">CGEventTapLocation</a> // */ // interface CGEventTapLocation { // /** // * Specifies that an event tap is placed at the point where HID system events enter the window server. // */ // int kCGHIDEventTap = 0; // // /** // * Specifies that an event tap is placed at the point where HID system and remote control events enter a login session. // */ // int kCGSessionEventTap = 1; // // /** // * Specifies that an event tap is placed at the point where session events have been annotated to flow to an application. // */ // int kCGAnnotatedSessionEventTap = 2; // } // } // Path: Customer/src/main/java/de/openindex/support/customer/utils/MacUtils.java import com.sun.jna.Native; import de.openindex.support.customer.utils.mac.CoreFoundation; import de.openindex.support.customer.utils.mac.CoreGraphics; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /* * Copyright 2015-2021 OpenIndex.de. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.openindex.support.customer.utils; /** * MacOS specific functions. * * @author Andreas Rudolph */ public class MacUtils { @SuppressWarnings("unused") private final static Logger LOGGER = LoggerFactory.getLogger(MacUtils.class);
private final static CoreFoundation CORE_FOUNDATION = loadCoreFoundation();
OpenIndex/RemoteSupportTool
Customer/src/main/java/de/openindex/support/customer/utils/MacUtils.java
// Path: Customer/src/main/java/de/openindex/support/customer/utils/mac/CoreFoundation.java // @SuppressWarnings("unused") // public interface CoreFoundation extends Library { // String JNA_LIBRARY_NAME = "CoreFoundation"; // // /** // * Releases a Core Foundation object. // * // * @param cf A CFType object to release. This value must not be NULL. // * @see <a href="https://developer.apple.com/documentation/corefoundation/1521153-cfrelease">CFRelease</a> // */ // void CFRelease(CFTypeRef cf); // // /** // * An untyped "generic" reference to any Core Foundation object. // * // * @see <a href="https://developer.apple.com/documentation/corefoundation/cftyperef">CFTypeRef</a> // */ // class CFTypeRef extends Structure { // } // } // // Path: Customer/src/main/java/de/openindex/support/customer/utils/mac/CoreGraphics.java // @SuppressWarnings("unused") // public interface CoreGraphics extends Library { // String JNA_LIBRARY_NAME = "CoreGraphics"; // // /** // * Returns a new Quartz keyboard event. // * // * @param source An event source taken from another event, or NULL. // * @param virtualKey The virtual key code for the event. // * @param keyDown Pass true to specify that the key position is down. To specify that the key position is up, pass false. This value is used to determine the type of the keyboard event // * @return A new keyboard event, or NULL if the event could not be created. When you no longer need the event, you should release it using the function CFRelease. // * @see <a href="https://developer.apple.com/documentation/coregraphics/1456564-cgeventcreatekeyboardevent">CGEventCreateKeyboardEvent</a> // */ // CGEventRef CGEventCreateKeyboardEvent(CGEventSourceRef source, char virtualKey, boolean keyDown); // // /** // * Sets the Unicode string associated with a Quartz keyboard event. // * // * @param event The keyboard event to access. // * @param stringLength The length of the array you provide in the unicodeString parameter. // * @param unicodeString An array that contains the new Unicode string associated with the specified event. // * @see <a href="https://developer.apple.com/documentation/coregraphics/1456028-cgeventkeyboardsetunicodestring">CGEventKeyboardSetUnicodeString</a> // */ // void CGEventKeyboardSetUnicodeString(CGEventRef event, int stringLength, char[] unicodeString); // //void CGEventKeyboardSetUnicodeString(CGEventRef event, int stringLength, String unicodeString); // // /** // * Posts a Quartz event into the event stream at a specified location. // * // * @param tap The location at which to post the event. Pass one of the constants listed in {@link CGEventTapLocation}. // * @param event The event to post. // * @see <a href="https://developer.apple.com/documentation/coregraphics/1456527-cgeventpost">CGEventPost</a> // */ // void CGEventPost(int tap, CGEventRef event); // // /** // * Defines an opaque type that represents a low-level hardware event. // * // * @see <a href="https://developer.apple.com/documentation/coregraphics/cgeventref">CGEventRef</a> // */ // @Structure.FieldOrder({"CFHashCode", "CFTypeID", "CFTypeRef"}) // class CGEventRef extends CoreFoundation.CFTypeRef { // public NativeLong CFHashCode; // public NativeLong CFTypeID; // public Pointer CFTypeRef; // } // // /** // * Defines an opaque type that represents the source of a Quartz event. // * // * @see <a href="https://developer.apple.com/documentation/coregraphics/cgeventsourceref">CGEventSourceRef</a> // */ // class CGEventSourceRef extends CoreFoundation.CFTypeRef { // // } // // /** // * Constants that specify possible tapping points for events. // * // * @see <a href="https://developer.apple.com/documentation/coregraphics/cgeventtaplocation">CGEventTapLocation</a> // */ // interface CGEventTapLocation { // /** // * Specifies that an event tap is placed at the point where HID system events enter the window server. // */ // int kCGHIDEventTap = 0; // // /** // * Specifies that an event tap is placed at the point where HID system and remote control events enter a login session. // */ // int kCGSessionEventTap = 1; // // /** // * Specifies that an event tap is placed at the point where session events have been annotated to flow to an application. // */ // int kCGAnnotatedSessionEventTap = 2; // } // }
import com.sun.jna.Native; import de.openindex.support.customer.utils.mac.CoreFoundation; import de.openindex.support.customer.utils.mac.CoreGraphics; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
/* * Copyright 2015-2021 OpenIndex.de. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.openindex.support.customer.utils; /** * MacOS specific functions. * * @author Andreas Rudolph */ public class MacUtils { @SuppressWarnings("unused") private final static Logger LOGGER = LoggerFactory.getLogger(MacUtils.class); private final static CoreFoundation CORE_FOUNDATION = loadCoreFoundation();
// Path: Customer/src/main/java/de/openindex/support/customer/utils/mac/CoreFoundation.java // @SuppressWarnings("unused") // public interface CoreFoundation extends Library { // String JNA_LIBRARY_NAME = "CoreFoundation"; // // /** // * Releases a Core Foundation object. // * // * @param cf A CFType object to release. This value must not be NULL. // * @see <a href="https://developer.apple.com/documentation/corefoundation/1521153-cfrelease">CFRelease</a> // */ // void CFRelease(CFTypeRef cf); // // /** // * An untyped "generic" reference to any Core Foundation object. // * // * @see <a href="https://developer.apple.com/documentation/corefoundation/cftyperef">CFTypeRef</a> // */ // class CFTypeRef extends Structure { // } // } // // Path: Customer/src/main/java/de/openindex/support/customer/utils/mac/CoreGraphics.java // @SuppressWarnings("unused") // public interface CoreGraphics extends Library { // String JNA_LIBRARY_NAME = "CoreGraphics"; // // /** // * Returns a new Quartz keyboard event. // * // * @param source An event source taken from another event, or NULL. // * @param virtualKey The virtual key code for the event. // * @param keyDown Pass true to specify that the key position is down. To specify that the key position is up, pass false. This value is used to determine the type of the keyboard event // * @return A new keyboard event, or NULL if the event could not be created. When you no longer need the event, you should release it using the function CFRelease. // * @see <a href="https://developer.apple.com/documentation/coregraphics/1456564-cgeventcreatekeyboardevent">CGEventCreateKeyboardEvent</a> // */ // CGEventRef CGEventCreateKeyboardEvent(CGEventSourceRef source, char virtualKey, boolean keyDown); // // /** // * Sets the Unicode string associated with a Quartz keyboard event. // * // * @param event The keyboard event to access. // * @param stringLength The length of the array you provide in the unicodeString parameter. // * @param unicodeString An array that contains the new Unicode string associated with the specified event. // * @see <a href="https://developer.apple.com/documentation/coregraphics/1456028-cgeventkeyboardsetunicodestring">CGEventKeyboardSetUnicodeString</a> // */ // void CGEventKeyboardSetUnicodeString(CGEventRef event, int stringLength, char[] unicodeString); // //void CGEventKeyboardSetUnicodeString(CGEventRef event, int stringLength, String unicodeString); // // /** // * Posts a Quartz event into the event stream at a specified location. // * // * @param tap The location at which to post the event. Pass one of the constants listed in {@link CGEventTapLocation}. // * @param event The event to post. // * @see <a href="https://developer.apple.com/documentation/coregraphics/1456527-cgeventpost">CGEventPost</a> // */ // void CGEventPost(int tap, CGEventRef event); // // /** // * Defines an opaque type that represents a low-level hardware event. // * // * @see <a href="https://developer.apple.com/documentation/coregraphics/cgeventref">CGEventRef</a> // */ // @Structure.FieldOrder({"CFHashCode", "CFTypeID", "CFTypeRef"}) // class CGEventRef extends CoreFoundation.CFTypeRef { // public NativeLong CFHashCode; // public NativeLong CFTypeID; // public Pointer CFTypeRef; // } // // /** // * Defines an opaque type that represents the source of a Quartz event. // * // * @see <a href="https://developer.apple.com/documentation/coregraphics/cgeventsourceref">CGEventSourceRef</a> // */ // class CGEventSourceRef extends CoreFoundation.CFTypeRef { // // } // // /** // * Constants that specify possible tapping points for events. // * // * @see <a href="https://developer.apple.com/documentation/coregraphics/cgeventtaplocation">CGEventTapLocation</a> // */ // interface CGEventTapLocation { // /** // * Specifies that an event tap is placed at the point where HID system events enter the window server. // */ // int kCGHIDEventTap = 0; // // /** // * Specifies that an event tap is placed at the point where HID system and remote control events enter a login session. // */ // int kCGSessionEventTap = 1; // // /** // * Specifies that an event tap is placed at the point where session events have been annotated to flow to an application. // */ // int kCGAnnotatedSessionEventTap = 2; // } // } // Path: Customer/src/main/java/de/openindex/support/customer/utils/MacUtils.java import com.sun.jna.Native; import de.openindex.support.customer.utils.mac.CoreFoundation; import de.openindex.support.customer.utils.mac.CoreGraphics; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /* * Copyright 2015-2021 OpenIndex.de. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.openindex.support.customer.utils; /** * MacOS specific functions. * * @author Andreas Rudolph */ public class MacUtils { @SuppressWarnings("unused") private final static Logger LOGGER = LoggerFactory.getLogger(MacUtils.class); private final static CoreFoundation CORE_FOUNDATION = loadCoreFoundation();
private final static CoreGraphics CORE_GRAPHICS = loadCoreGraphics();
appwoodoo/appwoodoo-android-sdk
SDK/appwoodoo/src/main/java/com/appwoodoo/sdk/dialogs/DialogFragment.java
// Path: SDK/appwoodoo/src/main/java/com/appwoodoo/sdk/storage/SharedPreferencesHelper.java // public final class SharedPreferencesHelper { // // private static SharedPreferencesHelper _instance; // private static SharedPreferences sp; // // private SharedPreferencesHelper() {} // // public static SharedPreferencesHelper getInstance() { // synchronized(SharedPreferencesHelper.class) { // if (_instance == null) { // _instance = new SharedPreferencesHelper(); // } // } // return _instance; // } // // public SharedPreferences getSharedPreferences(Context context) { // if (sp == null) { // String PREFERENCES_ID = "APPWOODOO_SHARED_PREFERENCES"; // sp = context.getSharedPreferences(PREFERENCES_ID, 0); // } // return sp; // } // // public void storeValue(SharedPreferences preferences, String key, Object value) { // SharedPreferences.Editor edit = preferences.edit(); // if (value == null) { // edit.remove(key); // } else if (value instanceof String) { // edit.putString(key, (String) value); // } else if (value instanceof Integer) { // edit.putInt(key, (Integer) value); // } // edit.apply(); // } // // public String getStoredString(SharedPreferences preferences, String key) { // return preferences.getString(key, ""); // } // // public Integer getStoredInteger(SharedPreferences preferences, String key) { // if (!preferences.contains(key)) { // return null; // } // return preferences.getInt(key, 0); // } // }
import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.graphics.Color; import android.graphics.PorterDuff; import android.graphics.Typeface; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.app.FragmentManager; import android.support.v7.appcompat.BuildConfig; import android.view.Gravity; import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.widget.Button; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.TextView; import com.appwoodoo.sdk.storage.SharedPreferencesHelper; import java.net.URL;
at.execute((Void) null); } builder.setView(linearLayout); if (dialogData.getTitle() != null) { LinearLayout titleLayout = new LinearLayout(getContext()); LinearLayout.LayoutParams titleLayoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); titleLayout.setLayoutParams(titleLayoutParams); linearLayout.setPadding(0, 0, 0, 0); titleLayout.setOrientation(LinearLayout.VERTICAL); TextView titleText = new TextView(getContext()); LinearLayout.LayoutParams titleParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); titleText.setLayoutParams(titleParams); titleParams.setMargins(35, 20, 35, 15); titleText.setPadding(5, 5, 5, 5); titleText.setGravity(Gravity.LEFT); titleText.setTextSize(26); titleText.setTextColor( DialogsHelper.getInstance().getViewOptions().getDialogTitleColour() ); if (typeface != null) { titleText.setTypeface(typeface); } titleText.setText(dialogData.getTitle()); titleLayout.addView(titleText); builder.setCustomTitle(titleLayout); }
// Path: SDK/appwoodoo/src/main/java/com/appwoodoo/sdk/storage/SharedPreferencesHelper.java // public final class SharedPreferencesHelper { // // private static SharedPreferencesHelper _instance; // private static SharedPreferences sp; // // private SharedPreferencesHelper() {} // // public static SharedPreferencesHelper getInstance() { // synchronized(SharedPreferencesHelper.class) { // if (_instance == null) { // _instance = new SharedPreferencesHelper(); // } // } // return _instance; // } // // public SharedPreferences getSharedPreferences(Context context) { // if (sp == null) { // String PREFERENCES_ID = "APPWOODOO_SHARED_PREFERENCES"; // sp = context.getSharedPreferences(PREFERENCES_ID, 0); // } // return sp; // } // // public void storeValue(SharedPreferences preferences, String key, Object value) { // SharedPreferences.Editor edit = preferences.edit(); // if (value == null) { // edit.remove(key); // } else if (value instanceof String) { // edit.putString(key, (String) value); // } else if (value instanceof Integer) { // edit.putInt(key, (Integer) value); // } // edit.apply(); // } // // public String getStoredString(SharedPreferences preferences, String key) { // return preferences.getString(key, ""); // } // // public Integer getStoredInteger(SharedPreferences preferences, String key) { // if (!preferences.contains(key)) { // return null; // } // return preferences.getInt(key, 0); // } // } // Path: SDK/appwoodoo/src/main/java/com/appwoodoo/sdk/dialogs/DialogFragment.java import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.graphics.Color; import android.graphics.PorterDuff; import android.graphics.Typeface; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.app.FragmentManager; import android.support.v7.appcompat.BuildConfig; import android.view.Gravity; import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.widget.Button; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.TextView; import com.appwoodoo.sdk.storage.SharedPreferencesHelper; import java.net.URL; at.execute((Void) null); } builder.setView(linearLayout); if (dialogData.getTitle() != null) { LinearLayout titleLayout = new LinearLayout(getContext()); LinearLayout.LayoutParams titleLayoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); titleLayout.setLayoutParams(titleLayoutParams); linearLayout.setPadding(0, 0, 0, 0); titleLayout.setOrientation(LinearLayout.VERTICAL); TextView titleText = new TextView(getContext()); LinearLayout.LayoutParams titleParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); titleText.setLayoutParams(titleParams); titleParams.setMargins(35, 20, 35, 15); titleText.setPadding(5, 5, 5, 5); titleText.setGravity(Gravity.LEFT); titleText.setTextSize(26); titleText.setTextColor( DialogsHelper.getInstance().getViewOptions().getDialogTitleColour() ); if (typeface != null) { titleText.setTypeface(typeface); } titleText.setText(dialogData.getTitle()); titleLayout.addView(titleText); builder.setCustomTitle(titleLayout); }
SharedPreferences preferences = SharedPreferencesHelper.getInstance().getSharedPreferences(getContext());
appwoodoo/appwoodoo-android-sdk
SDK/appwoodoo/src/main/java/com/appwoodoo/sdk/state/State.java
// Path: SDK/appwoodoo/src/main/java/com/appwoodoo/sdk/model/RemoteSetting.java // public class RemoteSetting { // // private String key; // private String value; // // public String getKey() { // return key; // } // // public void setKey(String key) { // this.key = key; // } // // public String getValue() { // return value; // } // // public void setValue(String value) { // this.value = value; // } // // public static ArrayList<RemoteSetting> parseJSON(String jsonString) { // if (jsonString == null) { // return null; // } // // ArrayList<RemoteSetting> woodoos = new ArrayList<RemoteSetting>(); // // try { // // JSONObject json = new JSONObject(jsonString); // // if (json.has("settings")) { // // JSONArray names = json.getJSONObject("settings").names(); // // for (int i=0; i<names.length(); i++) { // RemoteSetting woodoo = new RemoteSetting(); // woodoo.setKey( names.getString(i) ); // woodoo.setValue( json.getJSONObject("settings").optString( woodoo.getKey() ) ); // // woodoos.add(woodoo); // } // // } // // } catch(Exception e) { // if (BuildConfig.DEBUG) { // e.printStackTrace(); // } // } // // return woodoos; // } // // } // // Path: SDK/appwoodoo/src/main/java/com/appwoodoo/sdk/storage/SharedPreferencesHelper.java // public final class SharedPreferencesHelper { // // private static SharedPreferencesHelper _instance; // private static SharedPreferences sp; // // private SharedPreferencesHelper() {} // // public static SharedPreferencesHelper getInstance() { // synchronized(SharedPreferencesHelper.class) { // if (_instance == null) { // _instance = new SharedPreferencesHelper(); // } // } // return _instance; // } // // public SharedPreferences getSharedPreferences(Context context) { // if (sp == null) { // String PREFERENCES_ID = "APPWOODOO_SHARED_PREFERENCES"; // sp = context.getSharedPreferences(PREFERENCES_ID, 0); // } // return sp; // } // // public void storeValue(SharedPreferences preferences, String key, Object value) { // SharedPreferences.Editor edit = preferences.edit(); // if (value == null) { // edit.remove(key); // } else if (value instanceof String) { // edit.putString(key, (String) value); // } else if (value instanceof Integer) { // edit.putInt(key, (Integer) value); // } // edit.apply(); // } // // public String getStoredString(SharedPreferences preferences, String key) { // return preferences.getString(key, ""); // } // // public Integer getStoredInteger(SharedPreferences preferences, String key) { // if (!preferences.contains(key)) { // return null; // } // return preferences.getInt(key, 0); // } // }
import java.util.ArrayList; import android.content.Context; import android.content.SharedPreferences; import android.content.pm.PackageInfo; import android.net.Uri; import com.appwoodoo.sdk.model.RemoteSetting; import com.appwoodoo.sdk.storage.SharedPreferencesHelper;
package com.appwoodoo.sdk.state; public class State { private String appKey; private String gcmSender; private String notificationIntentClassName; private String notificationTitle; private Integer notificationResourceId; private String notificationSound; private String packageName;
// Path: SDK/appwoodoo/src/main/java/com/appwoodoo/sdk/model/RemoteSetting.java // public class RemoteSetting { // // private String key; // private String value; // // public String getKey() { // return key; // } // // public void setKey(String key) { // this.key = key; // } // // public String getValue() { // return value; // } // // public void setValue(String value) { // this.value = value; // } // // public static ArrayList<RemoteSetting> parseJSON(String jsonString) { // if (jsonString == null) { // return null; // } // // ArrayList<RemoteSetting> woodoos = new ArrayList<RemoteSetting>(); // // try { // // JSONObject json = new JSONObject(jsonString); // // if (json.has("settings")) { // // JSONArray names = json.getJSONObject("settings").names(); // // for (int i=0; i<names.length(); i++) { // RemoteSetting woodoo = new RemoteSetting(); // woodoo.setKey( names.getString(i) ); // woodoo.setValue( json.getJSONObject("settings").optString( woodoo.getKey() ) ); // // woodoos.add(woodoo); // } // // } // // } catch(Exception e) { // if (BuildConfig.DEBUG) { // e.printStackTrace(); // } // } // // return woodoos; // } // // } // // Path: SDK/appwoodoo/src/main/java/com/appwoodoo/sdk/storage/SharedPreferencesHelper.java // public final class SharedPreferencesHelper { // // private static SharedPreferencesHelper _instance; // private static SharedPreferences sp; // // private SharedPreferencesHelper() {} // // public static SharedPreferencesHelper getInstance() { // synchronized(SharedPreferencesHelper.class) { // if (_instance == null) { // _instance = new SharedPreferencesHelper(); // } // } // return _instance; // } // // public SharedPreferences getSharedPreferences(Context context) { // if (sp == null) { // String PREFERENCES_ID = "APPWOODOO_SHARED_PREFERENCES"; // sp = context.getSharedPreferences(PREFERENCES_ID, 0); // } // return sp; // } // // public void storeValue(SharedPreferences preferences, String key, Object value) { // SharedPreferences.Editor edit = preferences.edit(); // if (value == null) { // edit.remove(key); // } else if (value instanceof String) { // edit.putString(key, (String) value); // } else if (value instanceof Integer) { // edit.putInt(key, (Integer) value); // } // edit.apply(); // } // // public String getStoredString(SharedPreferences preferences, String key) { // return preferences.getString(key, ""); // } // // public Integer getStoredInteger(SharedPreferences preferences, String key) { // if (!preferences.contains(key)) { // return null; // } // return preferences.getInt(key, 0); // } // } // Path: SDK/appwoodoo/src/main/java/com/appwoodoo/sdk/state/State.java import java.util.ArrayList; import android.content.Context; import android.content.SharedPreferences; import android.content.pm.PackageInfo; import android.net.Uri; import com.appwoodoo.sdk.model.RemoteSetting; import com.appwoodoo.sdk.storage.SharedPreferencesHelper; package com.appwoodoo.sdk.state; public class State { private String appKey; private String gcmSender; private String notificationIntentClassName; private String notificationTitle; private Integer notificationResourceId; private String notificationSound; private String packageName;
private ArrayList<RemoteSetting> settings;
appwoodoo/appwoodoo-android-sdk
SDK/appwoodoo/src/main/java/com/appwoodoo/sdk/state/State.java
// Path: SDK/appwoodoo/src/main/java/com/appwoodoo/sdk/model/RemoteSetting.java // public class RemoteSetting { // // private String key; // private String value; // // public String getKey() { // return key; // } // // public void setKey(String key) { // this.key = key; // } // // public String getValue() { // return value; // } // // public void setValue(String value) { // this.value = value; // } // // public static ArrayList<RemoteSetting> parseJSON(String jsonString) { // if (jsonString == null) { // return null; // } // // ArrayList<RemoteSetting> woodoos = new ArrayList<RemoteSetting>(); // // try { // // JSONObject json = new JSONObject(jsonString); // // if (json.has("settings")) { // // JSONArray names = json.getJSONObject("settings").names(); // // for (int i=0; i<names.length(); i++) { // RemoteSetting woodoo = new RemoteSetting(); // woodoo.setKey( names.getString(i) ); // woodoo.setValue( json.getJSONObject("settings").optString( woodoo.getKey() ) ); // // woodoos.add(woodoo); // } // // } // // } catch(Exception e) { // if (BuildConfig.DEBUG) { // e.printStackTrace(); // } // } // // return woodoos; // } // // } // // Path: SDK/appwoodoo/src/main/java/com/appwoodoo/sdk/storage/SharedPreferencesHelper.java // public final class SharedPreferencesHelper { // // private static SharedPreferencesHelper _instance; // private static SharedPreferences sp; // // private SharedPreferencesHelper() {} // // public static SharedPreferencesHelper getInstance() { // synchronized(SharedPreferencesHelper.class) { // if (_instance == null) { // _instance = new SharedPreferencesHelper(); // } // } // return _instance; // } // // public SharedPreferences getSharedPreferences(Context context) { // if (sp == null) { // String PREFERENCES_ID = "APPWOODOO_SHARED_PREFERENCES"; // sp = context.getSharedPreferences(PREFERENCES_ID, 0); // } // return sp; // } // // public void storeValue(SharedPreferences preferences, String key, Object value) { // SharedPreferences.Editor edit = preferences.edit(); // if (value == null) { // edit.remove(key); // } else if (value instanceof String) { // edit.putString(key, (String) value); // } else if (value instanceof Integer) { // edit.putInt(key, (Integer) value); // } // edit.apply(); // } // // public String getStoredString(SharedPreferences preferences, String key) { // return preferences.getString(key, ""); // } // // public Integer getStoredInteger(SharedPreferences preferences, String key) { // if (!preferences.contains(key)) { // return null; // } // return preferences.getInt(key, 0); // } // }
import java.util.ArrayList; import android.content.Context; import android.content.SharedPreferences; import android.content.pm.PackageInfo; import android.net.Uri; import com.appwoodoo.sdk.model.RemoteSetting; import com.appwoodoo.sdk.storage.SharedPreferencesHelper;
private State() {} public static State getInstance() { synchronized(State.class) { if (_instance == null) { _instance = new State(); } } return _instance; } public String getAppKey() { return appKey; } public void setAppKey(String appKey) { this.appKey = appKey; } public String getPackageName() { return packageName; } public void setPackageName(Context context) { packageName = context.getPackageName(); } public String getGcmSender(Context context) { if (gcmSender == null) {
// Path: SDK/appwoodoo/src/main/java/com/appwoodoo/sdk/model/RemoteSetting.java // public class RemoteSetting { // // private String key; // private String value; // // public String getKey() { // return key; // } // // public void setKey(String key) { // this.key = key; // } // // public String getValue() { // return value; // } // // public void setValue(String value) { // this.value = value; // } // // public static ArrayList<RemoteSetting> parseJSON(String jsonString) { // if (jsonString == null) { // return null; // } // // ArrayList<RemoteSetting> woodoos = new ArrayList<RemoteSetting>(); // // try { // // JSONObject json = new JSONObject(jsonString); // // if (json.has("settings")) { // // JSONArray names = json.getJSONObject("settings").names(); // // for (int i=0; i<names.length(); i++) { // RemoteSetting woodoo = new RemoteSetting(); // woodoo.setKey( names.getString(i) ); // woodoo.setValue( json.getJSONObject("settings").optString( woodoo.getKey() ) ); // // woodoos.add(woodoo); // } // // } // // } catch(Exception e) { // if (BuildConfig.DEBUG) { // e.printStackTrace(); // } // } // // return woodoos; // } // // } // // Path: SDK/appwoodoo/src/main/java/com/appwoodoo/sdk/storage/SharedPreferencesHelper.java // public final class SharedPreferencesHelper { // // private static SharedPreferencesHelper _instance; // private static SharedPreferences sp; // // private SharedPreferencesHelper() {} // // public static SharedPreferencesHelper getInstance() { // synchronized(SharedPreferencesHelper.class) { // if (_instance == null) { // _instance = new SharedPreferencesHelper(); // } // } // return _instance; // } // // public SharedPreferences getSharedPreferences(Context context) { // if (sp == null) { // String PREFERENCES_ID = "APPWOODOO_SHARED_PREFERENCES"; // sp = context.getSharedPreferences(PREFERENCES_ID, 0); // } // return sp; // } // // public void storeValue(SharedPreferences preferences, String key, Object value) { // SharedPreferences.Editor edit = preferences.edit(); // if (value == null) { // edit.remove(key); // } else if (value instanceof String) { // edit.putString(key, (String) value); // } else if (value instanceof Integer) { // edit.putInt(key, (Integer) value); // } // edit.apply(); // } // // public String getStoredString(SharedPreferences preferences, String key) { // return preferences.getString(key, ""); // } // // public Integer getStoredInteger(SharedPreferences preferences, String key) { // if (!preferences.contains(key)) { // return null; // } // return preferences.getInt(key, 0); // } // } // Path: SDK/appwoodoo/src/main/java/com/appwoodoo/sdk/state/State.java import java.util.ArrayList; import android.content.Context; import android.content.SharedPreferences; import android.content.pm.PackageInfo; import android.net.Uri; import com.appwoodoo.sdk.model.RemoteSetting; import com.appwoodoo.sdk.storage.SharedPreferencesHelper; private State() {} public static State getInstance() { synchronized(State.class) { if (_instance == null) { _instance = new State(); } } return _instance; } public String getAppKey() { return appKey; } public void setAppKey(String appKey) { this.appKey = appKey; } public String getPackageName() { return packageName; } public void setPackageName(Context context) { packageName = context.getPackageName(); } public String getGcmSender(Context context) { if (gcmSender == null) {
SharedPreferences sp = SharedPreferencesHelper.getInstance().getSharedPreferences(context);
mdeverdelhan/OCA-Java-SE-7-Programmer-I
src/main/java/eu/verdelhan/ocajexam/chapter1/ex1_3/GreetingsUniverse.java
// Path: src/main/java/eu/verdelhan/ocajexam/chapter1/ex1_3/planets/Earth.java // public class Earth { // // public Earth() { // System.out.println("Hello from Earth!"); // } // } // // Path: src/main/java/eu/verdelhan/ocajexam/chapter1/ex1_3/planets/Mars.java // public class Mars { // // public Mars() { // System.out.println("Hello from Mars!"); // } // } // // Path: src/main/java/eu/verdelhan/ocajexam/chapter1/ex1_3/planets/Venus.java // public class Venus { // // public Venus() { // System.out.println("Hello from Venus!"); // } // }
import eu.verdelhan.ocajexam.chapter1.ex1_3.planets.Earth; import eu.verdelhan.ocajexam.chapter1.ex1_3.planets.Mars; import eu.verdelhan.ocajexam.chapter1.ex1_3.planets.Venus;
package eu.verdelhan.ocajexam.chapter1.ex1_3; public class GreetingsUniverse { public static void main(String[] args) { System.out.println("Greetings, Universe!");
// Path: src/main/java/eu/verdelhan/ocajexam/chapter1/ex1_3/planets/Earth.java // public class Earth { // // public Earth() { // System.out.println("Hello from Earth!"); // } // } // // Path: src/main/java/eu/verdelhan/ocajexam/chapter1/ex1_3/planets/Mars.java // public class Mars { // // public Mars() { // System.out.println("Hello from Mars!"); // } // } // // Path: src/main/java/eu/verdelhan/ocajexam/chapter1/ex1_3/planets/Venus.java // public class Venus { // // public Venus() { // System.out.println("Hello from Venus!"); // } // } // Path: src/main/java/eu/verdelhan/ocajexam/chapter1/ex1_3/GreetingsUniverse.java import eu.verdelhan.ocajexam.chapter1.ex1_3.planets.Earth; import eu.verdelhan.ocajexam.chapter1.ex1_3.planets.Mars; import eu.verdelhan.ocajexam.chapter1.ex1_3.planets.Venus; package eu.verdelhan.ocajexam.chapter1.ex1_3; public class GreetingsUniverse { public static void main(String[] args) { System.out.println("Greetings, Universe!");
Earth e = new Earth();
mdeverdelhan/OCA-Java-SE-7-Programmer-I
src/main/java/eu/verdelhan/ocajexam/chapter1/ex1_3/GreetingsUniverse.java
// Path: src/main/java/eu/verdelhan/ocajexam/chapter1/ex1_3/planets/Earth.java // public class Earth { // // public Earth() { // System.out.println("Hello from Earth!"); // } // } // // Path: src/main/java/eu/verdelhan/ocajexam/chapter1/ex1_3/planets/Mars.java // public class Mars { // // public Mars() { // System.out.println("Hello from Mars!"); // } // } // // Path: src/main/java/eu/verdelhan/ocajexam/chapter1/ex1_3/planets/Venus.java // public class Venus { // // public Venus() { // System.out.println("Hello from Venus!"); // } // }
import eu.verdelhan.ocajexam.chapter1.ex1_3.planets.Earth; import eu.verdelhan.ocajexam.chapter1.ex1_3.planets.Mars; import eu.verdelhan.ocajexam.chapter1.ex1_3.planets.Venus;
package eu.verdelhan.ocajexam.chapter1.ex1_3; public class GreetingsUniverse { public static void main(String[] args) { System.out.println("Greetings, Universe!"); Earth e = new Earth();
// Path: src/main/java/eu/verdelhan/ocajexam/chapter1/ex1_3/planets/Earth.java // public class Earth { // // public Earth() { // System.out.println("Hello from Earth!"); // } // } // // Path: src/main/java/eu/verdelhan/ocajexam/chapter1/ex1_3/planets/Mars.java // public class Mars { // // public Mars() { // System.out.println("Hello from Mars!"); // } // } // // Path: src/main/java/eu/verdelhan/ocajexam/chapter1/ex1_3/planets/Venus.java // public class Venus { // // public Venus() { // System.out.println("Hello from Venus!"); // } // } // Path: src/main/java/eu/verdelhan/ocajexam/chapter1/ex1_3/GreetingsUniverse.java import eu.verdelhan.ocajexam.chapter1.ex1_3.planets.Earth; import eu.verdelhan.ocajexam.chapter1.ex1_3.planets.Mars; import eu.verdelhan.ocajexam.chapter1.ex1_3.planets.Venus; package eu.verdelhan.ocajexam.chapter1.ex1_3; public class GreetingsUniverse { public static void main(String[] args) { System.out.println("Greetings, Universe!"); Earth e = new Earth();
Mars m = new Mars();
mdeverdelhan/OCA-Java-SE-7-Programmer-I
src/main/java/eu/verdelhan/ocajexam/chapter1/ex1_3/GreetingsUniverse.java
// Path: src/main/java/eu/verdelhan/ocajexam/chapter1/ex1_3/planets/Earth.java // public class Earth { // // public Earth() { // System.out.println("Hello from Earth!"); // } // } // // Path: src/main/java/eu/verdelhan/ocajexam/chapter1/ex1_3/planets/Mars.java // public class Mars { // // public Mars() { // System.out.println("Hello from Mars!"); // } // } // // Path: src/main/java/eu/verdelhan/ocajexam/chapter1/ex1_3/planets/Venus.java // public class Venus { // // public Venus() { // System.out.println("Hello from Venus!"); // } // }
import eu.verdelhan.ocajexam.chapter1.ex1_3.planets.Earth; import eu.verdelhan.ocajexam.chapter1.ex1_3.planets.Mars; import eu.verdelhan.ocajexam.chapter1.ex1_3.planets.Venus;
package eu.verdelhan.ocajexam.chapter1.ex1_3; public class GreetingsUniverse { public static void main(String[] args) { System.out.println("Greetings, Universe!"); Earth e = new Earth(); Mars m = new Mars();
// Path: src/main/java/eu/verdelhan/ocajexam/chapter1/ex1_3/planets/Earth.java // public class Earth { // // public Earth() { // System.out.println("Hello from Earth!"); // } // } // // Path: src/main/java/eu/verdelhan/ocajexam/chapter1/ex1_3/planets/Mars.java // public class Mars { // // public Mars() { // System.out.println("Hello from Mars!"); // } // } // // Path: src/main/java/eu/verdelhan/ocajexam/chapter1/ex1_3/planets/Venus.java // public class Venus { // // public Venus() { // System.out.println("Hello from Venus!"); // } // } // Path: src/main/java/eu/verdelhan/ocajexam/chapter1/ex1_3/GreetingsUniverse.java import eu.verdelhan.ocajexam.chapter1.ex1_3.planets.Earth; import eu.verdelhan.ocajexam.chapter1.ex1_3.planets.Mars; import eu.verdelhan.ocajexam.chapter1.ex1_3.planets.Venus; package eu.verdelhan.ocajexam.chapter1.ex1_3; public class GreetingsUniverse { public static void main(String[] args) { System.out.println("Greetings, Universe!"); Earth e = new Earth(); Mars m = new Mars();
Venus v = new Venus();
shamanland/xdroid
lib-app/src/main/java/xdroid/app/ApplicationX.java
// Path: lib-core/src/main/java/xdroid/core/ActivityStarter.java // public interface ActivityStarter { // void startActivity(Intent intent); // // void startActivityForResult(Intent intent, int requestCode); // } // // Path: lib-core/src/main/java/xdroid/core/ContextOwner.java // public interface ContextOwner { // Context getContext(); // } // // Path: lib-core/src/main/java/xdroid/core/Global.java // public final class Global { // private static Context sContext; // // private Global() { // // disallow public access // } // // public static void setContext(Context context) { // sContext = context; // } // // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // public static Resources getResources() { // return notNull(getContext().getResources()); // } // // public static Handler getUiHandler() { // return UiHandlerHolder.INSTANCE; // } // // public static Handler getBackgroundHandler() { // return BackgroundHandlerHolder.INSTANCE; // } // // static class CurrentApplicationHolder { // static final Application INSTANCE; // // static { // try { // Class<?> clazz = Class.forName("android.app.ActivityThread"); // Method method = ReflectUtils.getMethod(clazz, "currentApplication"); // INSTANCE = cast(ReflectUtils.invokeStaticMethod(method)); // } catch (Throwable ex) { // throw new AssertionError(ex); // } // } // } // // static class UiHandlerHolder { // static final Handler INSTANCE = new Handler(Looper.getMainLooper()); // } // // static class BackgroundHandlerHolder { // static final Handler INSTANCE = ThreadUtils.newThread(Global.class.getSimpleName(), null); // } // }
import android.app.Application; import android.content.Context; import android.content.Intent; import xdroid.core.ActivityStarter; import xdroid.core.ContextOwner; import xdroid.core.Global;
package xdroid.app; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ public class ApplicationX extends Application implements ActivityStarter, ContextOwner { @Override public Context getContext() { return this; } @Override public void startActivityForResult(Intent intent, int requestCode) { startActivity(intent); } @Override protected void attachBaseContext(Context base) {
// Path: lib-core/src/main/java/xdroid/core/ActivityStarter.java // public interface ActivityStarter { // void startActivity(Intent intent); // // void startActivityForResult(Intent intent, int requestCode); // } // // Path: lib-core/src/main/java/xdroid/core/ContextOwner.java // public interface ContextOwner { // Context getContext(); // } // // Path: lib-core/src/main/java/xdroid/core/Global.java // public final class Global { // private static Context sContext; // // private Global() { // // disallow public access // } // // public static void setContext(Context context) { // sContext = context; // } // // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // public static Resources getResources() { // return notNull(getContext().getResources()); // } // // public static Handler getUiHandler() { // return UiHandlerHolder.INSTANCE; // } // // public static Handler getBackgroundHandler() { // return BackgroundHandlerHolder.INSTANCE; // } // // static class CurrentApplicationHolder { // static final Application INSTANCE; // // static { // try { // Class<?> clazz = Class.forName("android.app.ActivityThread"); // Method method = ReflectUtils.getMethod(clazz, "currentApplication"); // INSTANCE = cast(ReflectUtils.invokeStaticMethod(method)); // } catch (Throwable ex) { // throw new AssertionError(ex); // } // } // } // // static class UiHandlerHolder { // static final Handler INSTANCE = new Handler(Looper.getMainLooper()); // } // // static class BackgroundHandlerHolder { // static final Handler INSTANCE = ThreadUtils.newThread(Global.class.getSimpleName(), null); // } // } // Path: lib-app/src/main/java/xdroid/app/ApplicationX.java import android.app.Application; import android.content.Context; import android.content.Intent; import xdroid.core.ActivityStarter; import xdroid.core.ContextOwner; import xdroid.core.Global; package xdroid.app; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ public class ApplicationX extends Application implements ActivityStarter, ContextOwner { @Override public Context getContext() { return this; } @Override public void startActivityForResult(Intent intent, int requestCode) { startActivity(intent); } @Override protected void attachBaseContext(Context base) {
Global.setContext(this);
shamanland/xdroid
lib-options/src/main/java/xdroid/options/EnumOption.java
// Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // }
import static xdroid.core.ObjectUtils.notNull;
package xdroid.options; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ public class EnumOption implements Option { private final Enum<?> mEnumConstant; public EnumOption(Enum<?> enumConstant) {
// Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // } // Path: lib-options/src/main/java/xdroid/options/EnumOption.java import static xdroid.core.ObjectUtils.notNull; package xdroid.options; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ public class EnumOption implements Option { private final Enum<?> mEnumConstant; public EnumOption(Enum<?> enumConstant) {
mEnumConstant = notNull(enumConstant);
shamanland/xdroid
lib-collections/src/main/java/xdroid/collections/ArrayIterator.java
// Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // }
import java.util.Iterator; import static xdroid.core.ObjectUtils.notNull;
package xdroid.collections; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ public class ArrayIterator<E> implements Iterator<E> { private final E[] mBase; private int mCursor; public ArrayIterator(E[] base) {
// Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // } // Path: lib-collections/src/main/java/xdroid/collections/ArrayIterator.java import java.util.Iterator; import static xdroid.core.ObjectUtils.notNull; package xdroid.collections; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ public class ArrayIterator<E> implements Iterator<E> { private final E[] mBase; private int mCursor; public ArrayIterator(E[] base) {
mBase = notNull(base);
shamanland/xdroid
lib-inflater/src/main/java/xdroid/inflater/AbstractInflater.java
// Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> boolean isEmpty(T[] array) { // return array == null || array.length == 0; // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // }
import android.content.Context; import android.content.res.Resources; import android.content.res.XmlResourceParser; import android.util.AttributeSet; import android.view.InflateException; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import java.io.IOException; import static xdroid.core.ObjectUtils.isEmpty; import static xdroid.core.ObjectUtils.notNull; import static xdroid.inflater.BuildConfig.SNAPSHOT;
package xdroid.inflater; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ public abstract class AbstractInflater<T, C extends T> { private final Class<C> mCompositeClazz; protected abstract T createFromTag(Context context, XmlPullParser parser, C parent, AttributeSet attrs) throws XmlPullParserException; protected AbstractInflater(Class<C> compositeClazz) {
// Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> boolean isEmpty(T[] array) { // return array == null || array.length == 0; // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // } // Path: lib-inflater/src/main/java/xdroid/inflater/AbstractInflater.java import android.content.Context; import android.content.res.Resources; import android.content.res.XmlResourceParser; import android.util.AttributeSet; import android.view.InflateException; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import java.io.IOException; import static xdroid.core.ObjectUtils.isEmpty; import static xdroid.core.ObjectUtils.notNull; import static xdroid.inflater.BuildConfig.SNAPSHOT; package xdroid.inflater; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ public abstract class AbstractInflater<T, C extends T> { private final Class<C> mCompositeClazz; protected abstract T createFromTag(Context context, XmlPullParser parser, C parent, AttributeSet attrs) throws XmlPullParserException; protected AbstractInflater(Class<C> compositeClazz) {
mCompositeClazz = notNull(compositeClazz);
shamanland/xdroid
lib-inflater/src/main/java/xdroid/inflater/AbstractInflater.java
// Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> boolean isEmpty(T[] array) { // return array == null || array.length == 0; // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // }
import android.content.Context; import android.content.res.Resources; import android.content.res.XmlResourceParser; import android.util.AttributeSet; import android.view.InflateException; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import java.io.IOException; import static xdroid.core.ObjectUtils.isEmpty; import static xdroid.core.ObjectUtils.notNull; import static xdroid.inflater.BuildConfig.SNAPSHOT;
return result; } catch (XmlPullParserException | IOException ex) { throw new InflateException(parser.getPositionDescription(), ex); } } private void inflateRec(Context context, XmlPullParser parser, C parent, AttributeSet attrs) throws XmlPullParserException, IOException { final int depth = parser.getDepth(); int type; while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) { if (type != XmlPullParser.START_TAG) { continue; } T item = notNull(createFromTag(context, parser, parent, attrs)); if (mCompositeClazz.isInstance(item)) { inflateRec(context, parser, mCompositeClazz.cast(item), attrs); } } } public static class MissedAttributeException extends XmlPullParserException { public MissedAttributeException(Context context, int[] styleableArray, int... attrIndices) { super(createMessage(context, styleableArray, attrIndices)); } public static String createMessage(Context context, int[] styleableArray, int... attrIndices) { if (SNAPSHOT) {
// Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> boolean isEmpty(T[] array) { // return array == null || array.length == 0; // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // } // Path: lib-inflater/src/main/java/xdroid/inflater/AbstractInflater.java import android.content.Context; import android.content.res.Resources; import android.content.res.XmlResourceParser; import android.util.AttributeSet; import android.view.InflateException; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import java.io.IOException; import static xdroid.core.ObjectUtils.isEmpty; import static xdroid.core.ObjectUtils.notNull; import static xdroid.inflater.BuildConfig.SNAPSHOT; return result; } catch (XmlPullParserException | IOException ex) { throw new InflateException(parser.getPositionDescription(), ex); } } private void inflateRec(Context context, XmlPullParser parser, C parent, AttributeSet attrs) throws XmlPullParserException, IOException { final int depth = parser.getDepth(); int type; while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) { if (type != XmlPullParser.START_TAG) { continue; } T item = notNull(createFromTag(context, parser, parent, attrs)); if (mCompositeClazz.isInstance(item)) { inflateRec(context, parser, mCompositeClazz.cast(item), attrs); } } } public static class MissedAttributeException extends XmlPullParserException { public MissedAttributeException(Context context, int[] styleableArray, int... attrIndices) { super(createMessage(context, styleableArray, attrIndices)); } public static String createMessage(Context context, int[] styleableArray, int... attrIndices) { if (SNAPSHOT) {
if (isEmpty(attrIndices)) {
shamanland/xdroid
lib-enum-format/src/main/java/xdroid/enumformat/EnumFormat.java
// Path: lib-core/src/main/java/xdroid/core/Global.java // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // Path: lib-core/src/main/java/xdroid/core/Global.java // public static Resources getResources() { // return notNull(getContext().getResources()); // }
import java.text.FieldPosition; import java.text.Format; import java.text.ParsePosition; import java.util.HashMap; import java.util.Locale; import java.util.Map; import static xdroid.core.Global.getContext; import static xdroid.core.Global.getResources;
package xdroid.enumformat; public class EnumFormat extends Format { private static final EnumFormat INSTANCE = new EnumFormat(); private Map<String, Integer> mCache; public static EnumFormat getInstance() { return INSTANCE; } public EnumFormat() { mCache = new HashMap<>(); } public synchronized void clearCache() { mCache.clear(); } protected synchronized Integer getCache(String fullName) { return mCache.get(fullName); } protected synchronized void putCache(String fullName, Integer value) { mCache.put(fullName, value); } /** * Add annotations {@link EnumString} to each of your <code>enum</code> constants. * If this annotation is not present, make sure you added corresponding <code>string</code> * to <code>res</code> folder with the same name (lower case) as your <code>enum</code> constant. * * @param e not null * @param <E> any enum type * @return localized string if it was correctly configured * @see EnumString */ public <E extends Enum<E>> String format(E e) { return format((Object) e); } @Override @SuppressWarnings("NullableProblems") public StringBuffer format(Object object, StringBuffer buffer, FieldPosition field) { if (object instanceof Enum) { Enum e = (Enum) object; int stringId = getStringId(e); if (stringId != 0) {
// Path: lib-core/src/main/java/xdroid/core/Global.java // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // Path: lib-core/src/main/java/xdroid/core/Global.java // public static Resources getResources() { // return notNull(getContext().getResources()); // } // Path: lib-enum-format/src/main/java/xdroid/enumformat/EnumFormat.java import java.text.FieldPosition; import java.text.Format; import java.text.ParsePosition; import java.util.HashMap; import java.util.Locale; import java.util.Map; import static xdroid.core.Global.getContext; import static xdroid.core.Global.getResources; package xdroid.enumformat; public class EnumFormat extends Format { private static final EnumFormat INSTANCE = new EnumFormat(); private Map<String, Integer> mCache; public static EnumFormat getInstance() { return INSTANCE; } public EnumFormat() { mCache = new HashMap<>(); } public synchronized void clearCache() { mCache.clear(); } protected synchronized Integer getCache(String fullName) { return mCache.get(fullName); } protected synchronized void putCache(String fullName, Integer value) { mCache.put(fullName, value); } /** * Add annotations {@link EnumString} to each of your <code>enum</code> constants. * If this annotation is not present, make sure you added corresponding <code>string</code> * to <code>res</code> folder with the same name (lower case) as your <code>enum</code> constant. * * @param e not null * @param <E> any enum type * @return localized string if it was correctly configured * @see EnumString */ public <E extends Enum<E>> String format(E e) { return format((Object) e); } @Override @SuppressWarnings("NullableProblems") public StringBuffer format(Object object, StringBuffer buffer, FieldPosition field) { if (object instanceof Enum) { Enum e = (Enum) object; int stringId = getStringId(e); if (stringId != 0) {
buffer.append(getResources().getText(stringId));
shamanland/xdroid
lib-enum-format/src/main/java/xdroid/enumformat/EnumFormat.java
// Path: lib-core/src/main/java/xdroid/core/Global.java // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // Path: lib-core/src/main/java/xdroid/core/Global.java // public static Resources getResources() { // return notNull(getContext().getResources()); // }
import java.text.FieldPosition; import java.text.Format; import java.text.ParsePosition; import java.util.HashMap; import java.util.Locale; import java.util.Map; import static xdroid.core.Global.getContext; import static xdroid.core.Global.getResources;
@SuppressWarnings("NullableProblems") public StringBuffer format(Object object, StringBuffer buffer, FieldPosition field) { if (object instanceof Enum) { Enum e = (Enum) object; int stringId = getStringId(e); if (stringId != 0) { buffer.append(getResources().getText(stringId)); } else { buffer.append(e.name()); } return buffer; } throw new IllegalArgumentException(String.valueOf(object)); } protected int getStringId(Enum e) { String fullName = e.getClass().getName() + "." + e.name(); Integer result = getCache(fullName); if (result != null) { return result; } EnumString a = getAnnotation(e); if (a != null) { result = a.value(); } else {
// Path: lib-core/src/main/java/xdroid/core/Global.java // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // Path: lib-core/src/main/java/xdroid/core/Global.java // public static Resources getResources() { // return notNull(getContext().getResources()); // } // Path: lib-enum-format/src/main/java/xdroid/enumformat/EnumFormat.java import java.text.FieldPosition; import java.text.Format; import java.text.ParsePosition; import java.util.HashMap; import java.util.Locale; import java.util.Map; import static xdroid.core.Global.getContext; import static xdroid.core.Global.getResources; @SuppressWarnings("NullableProblems") public StringBuffer format(Object object, StringBuffer buffer, FieldPosition field) { if (object instanceof Enum) { Enum e = (Enum) object; int stringId = getStringId(e); if (stringId != 0) { buffer.append(getResources().getText(stringId)); } else { buffer.append(e.name()); } return buffer; } throw new IllegalArgumentException(String.valueOf(object)); } protected int getStringId(Enum e) { String fullName = e.getClass().getName() + "." + e.name(); Integer result = getCache(fullName); if (result != null) { return result; } EnumString a = getAnnotation(e); if (a != null) { result = a.value(); } else {
result = getResources().getIdentifier(e.name().toLowerCase(Locale.US), "string", getContext().getPackageName());
shamanland/xdroid
lib-options/src/main/java/xdroid/options/SimpleOption.java
// Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T[] notEmpty(T[] array) { // if (isEmpty(array)) { // throw new IllegalArgumentException(Arrays.toString(array)); // } // // return array; // }
import static xdroid.core.ObjectUtils.notEmpty;
package xdroid.options; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ public class SimpleOption implements Option { private final String mName; public final OptionAccessor.Getter get; public final OptionAccessor.Setter set; @Override public String getName() { return mName; } public SimpleOption(String name, OptionAccessor accessor) {
// Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T[] notEmpty(T[] array) { // if (isEmpty(array)) { // throw new IllegalArgumentException(Arrays.toString(array)); // } // // return array; // } // Path: lib-options/src/main/java/xdroid/options/SimpleOption.java import static xdroid.core.ObjectUtils.notEmpty; package xdroid.options; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ public class SimpleOption implements Option { private final String mName; public final OptionAccessor.Getter get; public final OptionAccessor.Setter set; @Override public String getName() { return mName; } public SimpleOption(String name, OptionAccessor accessor) {
mName = notEmpty(name);
shamanland/xdroid
lib-collections/src/main/java/xdroid/collections/IndexedIterator.java
// Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // }
import java.util.Iterator; import static xdroid.core.ObjectUtils.notNull;
package xdroid.collections; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ public class IndexedIterator<E> implements Iterator<E> { private final Indexed<E> mIndexed; private int mCursor; public IndexedIterator(Indexed<E> indexed) {
// Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // } // Path: lib-collections/src/main/java/xdroid/collections/IndexedIterator.java import java.util.Iterator; import static xdroid.core.ObjectUtils.notNull; package xdroid.collections; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ public class IndexedIterator<E> implements Iterator<E> { private final Indexed<E> mIndexed; private int mCursor; public IndexedIterator(Indexed<E> indexed) {
mIndexed = notNull(indexed);
shamanland/xdroid
lib-options/src/main/java/xdroid/options/OptionAccessor.java
// Path: lib-core/src/main/java/xdroid/core/Global.java // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // @SuppressWarnings("unchecked") // public static <T> T cast(Object object) { // return (T) object; // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static boolean getBoolean(SharedPreferences prefs, String key, boolean defaultValue) { // try { // return prefs.getBoolean(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static float getFloat(SharedPreferences prefs, String key, float defaultValue) { // try { // return prefs.getFloat(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static int getInt(SharedPreferences prefs, String key, int defaultValue) { // try { // return prefs.getInt(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static long getLong(SharedPreferences prefs, String key, long defaultValue) { // try { // return prefs.getLong(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static String getString(SharedPreferences prefs, String key, String defaultValue) { // try { // return prefs.getString(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static Set<String> getStringSet(SharedPreferences prefs, String key, Set<String> defaultValue) { // try { // return prefs.getStringSet(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // }
import android.content.Context; import android.content.SharedPreferences; import java.util.Collections; import java.util.HashSet; import java.util.Set; import static xdroid.core.Global.getContext; import static xdroid.core.ObjectUtils.cast; import static xdroid.core.ObjectUtils.notNull; import static xdroid.core.SharedPreferencesUtils.getBoolean; import static xdroid.core.SharedPreferencesUtils.getFloat; import static xdroid.core.SharedPreferencesUtils.getInt; import static xdroid.core.SharedPreferencesUtils.getLong; import static xdroid.core.SharedPreferencesUtils.getString; import static xdroid.core.SharedPreferencesUtils.getStringSet;
package xdroid.options; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ public class OptionAccessor { private final Object mDefaultValue; private final Getter mGetter; private final Setter mSetter; private Object mValue; private Option mOption; public void setEnumConst(Enum<?> enumConst) { mOption = new EnumOption(enumConst); } public void setOption(Option option) {
// Path: lib-core/src/main/java/xdroid/core/Global.java // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // @SuppressWarnings("unchecked") // public static <T> T cast(Object object) { // return (T) object; // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static boolean getBoolean(SharedPreferences prefs, String key, boolean defaultValue) { // try { // return prefs.getBoolean(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static float getFloat(SharedPreferences prefs, String key, float defaultValue) { // try { // return prefs.getFloat(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static int getInt(SharedPreferences prefs, String key, int defaultValue) { // try { // return prefs.getInt(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static long getLong(SharedPreferences prefs, String key, long defaultValue) { // try { // return prefs.getLong(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static String getString(SharedPreferences prefs, String key, String defaultValue) { // try { // return prefs.getString(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static Set<String> getStringSet(SharedPreferences prefs, String key, Set<String> defaultValue) { // try { // return prefs.getStringSet(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // Path: lib-options/src/main/java/xdroid/options/OptionAccessor.java import android.content.Context; import android.content.SharedPreferences; import java.util.Collections; import java.util.HashSet; import java.util.Set; import static xdroid.core.Global.getContext; import static xdroid.core.ObjectUtils.cast; import static xdroid.core.ObjectUtils.notNull; import static xdroid.core.SharedPreferencesUtils.getBoolean; import static xdroid.core.SharedPreferencesUtils.getFloat; import static xdroid.core.SharedPreferencesUtils.getInt; import static xdroid.core.SharedPreferencesUtils.getLong; import static xdroid.core.SharedPreferencesUtils.getString; import static xdroid.core.SharedPreferencesUtils.getStringSet; package xdroid.options; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ public class OptionAccessor { private final Object mDefaultValue; private final Getter mGetter; private final Setter mSetter; private Object mValue; private Option mOption; public void setEnumConst(Enum<?> enumConst) { mOption = new EnumOption(enumConst); } public void setOption(Option option) {
mOption = notNull(option);
shamanland/xdroid
lib-options/src/main/java/xdroid/options/OptionAccessor.java
// Path: lib-core/src/main/java/xdroid/core/Global.java // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // @SuppressWarnings("unchecked") // public static <T> T cast(Object object) { // return (T) object; // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static boolean getBoolean(SharedPreferences prefs, String key, boolean defaultValue) { // try { // return prefs.getBoolean(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static float getFloat(SharedPreferences prefs, String key, float defaultValue) { // try { // return prefs.getFloat(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static int getInt(SharedPreferences prefs, String key, int defaultValue) { // try { // return prefs.getInt(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static long getLong(SharedPreferences prefs, String key, long defaultValue) { // try { // return prefs.getLong(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static String getString(SharedPreferences prefs, String key, String defaultValue) { // try { // return prefs.getString(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static Set<String> getStringSet(SharedPreferences prefs, String key, Set<String> defaultValue) { // try { // return prefs.getStringSet(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // }
import android.content.Context; import android.content.SharedPreferences; import java.util.Collections; import java.util.HashSet; import java.util.Set; import static xdroid.core.Global.getContext; import static xdroid.core.ObjectUtils.cast; import static xdroid.core.ObjectUtils.notNull; import static xdroid.core.SharedPreferencesUtils.getBoolean; import static xdroid.core.SharedPreferencesUtils.getFloat; import static xdroid.core.SharedPreferencesUtils.getInt; import static xdroid.core.SharedPreferencesUtils.getLong; import static xdroid.core.SharedPreferencesUtils.getString; import static xdroid.core.SharedPreferencesUtils.getStringSet;
package xdroid.options; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ public class OptionAccessor { private final Object mDefaultValue; private final Getter mGetter; private final Setter mSetter; private Object mValue; private Option mOption; public void setEnumConst(Enum<?> enumConst) { mOption = new EnumOption(enumConst); } public void setOption(Option option) { mOption = notNull(option); } public Getter getter() { return mGetter; } public Setter setter() { return mSetter; } private SharedPreferences getPrefs() {
// Path: lib-core/src/main/java/xdroid/core/Global.java // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // @SuppressWarnings("unchecked") // public static <T> T cast(Object object) { // return (T) object; // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static boolean getBoolean(SharedPreferences prefs, String key, boolean defaultValue) { // try { // return prefs.getBoolean(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static float getFloat(SharedPreferences prefs, String key, float defaultValue) { // try { // return prefs.getFloat(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static int getInt(SharedPreferences prefs, String key, int defaultValue) { // try { // return prefs.getInt(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static long getLong(SharedPreferences prefs, String key, long defaultValue) { // try { // return prefs.getLong(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static String getString(SharedPreferences prefs, String key, String defaultValue) { // try { // return prefs.getString(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static Set<String> getStringSet(SharedPreferences prefs, String key, Set<String> defaultValue) { // try { // return prefs.getStringSet(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // Path: lib-options/src/main/java/xdroid/options/OptionAccessor.java import android.content.Context; import android.content.SharedPreferences; import java.util.Collections; import java.util.HashSet; import java.util.Set; import static xdroid.core.Global.getContext; import static xdroid.core.ObjectUtils.cast; import static xdroid.core.ObjectUtils.notNull; import static xdroid.core.SharedPreferencesUtils.getBoolean; import static xdroid.core.SharedPreferencesUtils.getFloat; import static xdroid.core.SharedPreferencesUtils.getInt; import static xdroid.core.SharedPreferencesUtils.getLong; import static xdroid.core.SharedPreferencesUtils.getString; import static xdroid.core.SharedPreferencesUtils.getStringSet; package xdroid.options; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ public class OptionAccessor { private final Object mDefaultValue; private final Getter mGetter; private final Setter mSetter; private Object mValue; private Option mOption; public void setEnumConst(Enum<?> enumConst) { mOption = new EnumOption(enumConst); } public void setOption(Option option) { mOption = notNull(option); } public Getter getter() { return mGetter; } public Setter setter() { return mSetter; } private SharedPreferences getPrefs() {
return getContext().getSharedPreferences(mOption.getClass().getName(), Context.MODE_PRIVATE);
shamanland/xdroid
lib-options/src/main/java/xdroid/options/OptionAccessor.java
// Path: lib-core/src/main/java/xdroid/core/Global.java // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // @SuppressWarnings("unchecked") // public static <T> T cast(Object object) { // return (T) object; // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static boolean getBoolean(SharedPreferences prefs, String key, boolean defaultValue) { // try { // return prefs.getBoolean(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static float getFloat(SharedPreferences prefs, String key, float defaultValue) { // try { // return prefs.getFloat(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static int getInt(SharedPreferences prefs, String key, int defaultValue) { // try { // return prefs.getInt(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static long getLong(SharedPreferences prefs, String key, long defaultValue) { // try { // return prefs.getLong(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static String getString(SharedPreferences prefs, String key, String defaultValue) { // try { // return prefs.getString(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static Set<String> getStringSet(SharedPreferences prefs, String key, Set<String> defaultValue) { // try { // return prefs.getStringSet(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // }
import android.content.Context; import android.content.SharedPreferences; import java.util.Collections; import java.util.HashSet; import java.util.Set; import static xdroid.core.Global.getContext; import static xdroid.core.ObjectUtils.cast; import static xdroid.core.ObjectUtils.notNull; import static xdroid.core.SharedPreferencesUtils.getBoolean; import static xdroid.core.SharedPreferencesUtils.getFloat; import static xdroid.core.SharedPreferencesUtils.getInt; import static xdroid.core.SharedPreferencesUtils.getLong; import static xdroid.core.SharedPreferencesUtils.getString; import static xdroid.core.SharedPreferencesUtils.getStringSet;
public class Setter { public boolean asInt(int value) { throw new UnsupportedOperationException(); } public boolean asLong(long value) { throw new UnsupportedOperationException(); } public boolean asFloat(float value) { throw new UnsupportedOperationException(); } public boolean asBoolean(boolean value) { throw new UnsupportedOperationException(); } public boolean asString(String value) { throw new UnsupportedOperationException(); } public boolean asStringSet(Set<String> value) { throw new UnsupportedOperationException(); } } protected class IntGetter extends Getter { public int asInt() { if (mValue == null) {
// Path: lib-core/src/main/java/xdroid/core/Global.java // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // @SuppressWarnings("unchecked") // public static <T> T cast(Object object) { // return (T) object; // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static boolean getBoolean(SharedPreferences prefs, String key, boolean defaultValue) { // try { // return prefs.getBoolean(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static float getFloat(SharedPreferences prefs, String key, float defaultValue) { // try { // return prefs.getFloat(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static int getInt(SharedPreferences prefs, String key, int defaultValue) { // try { // return prefs.getInt(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static long getLong(SharedPreferences prefs, String key, long defaultValue) { // try { // return prefs.getLong(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static String getString(SharedPreferences prefs, String key, String defaultValue) { // try { // return prefs.getString(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static Set<String> getStringSet(SharedPreferences prefs, String key, Set<String> defaultValue) { // try { // return prefs.getStringSet(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // Path: lib-options/src/main/java/xdroid/options/OptionAccessor.java import android.content.Context; import android.content.SharedPreferences; import java.util.Collections; import java.util.HashSet; import java.util.Set; import static xdroid.core.Global.getContext; import static xdroid.core.ObjectUtils.cast; import static xdroid.core.ObjectUtils.notNull; import static xdroid.core.SharedPreferencesUtils.getBoolean; import static xdroid.core.SharedPreferencesUtils.getFloat; import static xdroid.core.SharedPreferencesUtils.getInt; import static xdroid.core.SharedPreferencesUtils.getLong; import static xdroid.core.SharedPreferencesUtils.getString; import static xdroid.core.SharedPreferencesUtils.getStringSet; public class Setter { public boolean asInt(int value) { throw new UnsupportedOperationException(); } public boolean asLong(long value) { throw new UnsupportedOperationException(); } public boolean asFloat(float value) { throw new UnsupportedOperationException(); } public boolean asBoolean(boolean value) { throw new UnsupportedOperationException(); } public boolean asString(String value) { throw new UnsupportedOperationException(); } public boolean asStringSet(Set<String> value) { throw new UnsupportedOperationException(); } } protected class IntGetter extends Getter { public int asInt() { if (mValue == null) {
mValue = getInt(getPrefs(), mOption.getName(), (Integer) mDefaultValue);
shamanland/xdroid
lib-options/src/main/java/xdroid/options/OptionAccessor.java
// Path: lib-core/src/main/java/xdroid/core/Global.java // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // @SuppressWarnings("unchecked") // public static <T> T cast(Object object) { // return (T) object; // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static boolean getBoolean(SharedPreferences prefs, String key, boolean defaultValue) { // try { // return prefs.getBoolean(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static float getFloat(SharedPreferences prefs, String key, float defaultValue) { // try { // return prefs.getFloat(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static int getInt(SharedPreferences prefs, String key, int defaultValue) { // try { // return prefs.getInt(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static long getLong(SharedPreferences prefs, String key, long defaultValue) { // try { // return prefs.getLong(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static String getString(SharedPreferences prefs, String key, String defaultValue) { // try { // return prefs.getString(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static Set<String> getStringSet(SharedPreferences prefs, String key, Set<String> defaultValue) { // try { // return prefs.getStringSet(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // }
import android.content.Context; import android.content.SharedPreferences; import java.util.Collections; import java.util.HashSet; import java.util.Set; import static xdroid.core.Global.getContext; import static xdroid.core.ObjectUtils.cast; import static xdroid.core.ObjectUtils.notNull; import static xdroid.core.SharedPreferencesUtils.getBoolean; import static xdroid.core.SharedPreferencesUtils.getFloat; import static xdroid.core.SharedPreferencesUtils.getInt; import static xdroid.core.SharedPreferencesUtils.getLong; import static xdroid.core.SharedPreferencesUtils.getString; import static xdroid.core.SharedPreferencesUtils.getStringSet;
throw new UnsupportedOperationException(); } public boolean asStringSet(Set<String> value) { throw new UnsupportedOperationException(); } } protected class IntGetter extends Getter { public int asInt() { if (mValue == null) { mValue = getInt(getPrefs(), mOption.getName(), (Integer) mDefaultValue); } return (Integer) mValue; } } protected class IntSetter extends Setter { public boolean asInt(int value) { boolean changed = isChanged(mValue, value); mValue = value; getPrefs().edit().putInt(mOption.getName(), value).apply(); return changed; } } protected class LongGetter extends Getter { public long asLong() { if (mValue == null) {
// Path: lib-core/src/main/java/xdroid/core/Global.java // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // @SuppressWarnings("unchecked") // public static <T> T cast(Object object) { // return (T) object; // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static boolean getBoolean(SharedPreferences prefs, String key, boolean defaultValue) { // try { // return prefs.getBoolean(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static float getFloat(SharedPreferences prefs, String key, float defaultValue) { // try { // return prefs.getFloat(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static int getInt(SharedPreferences prefs, String key, int defaultValue) { // try { // return prefs.getInt(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static long getLong(SharedPreferences prefs, String key, long defaultValue) { // try { // return prefs.getLong(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static String getString(SharedPreferences prefs, String key, String defaultValue) { // try { // return prefs.getString(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static Set<String> getStringSet(SharedPreferences prefs, String key, Set<String> defaultValue) { // try { // return prefs.getStringSet(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // Path: lib-options/src/main/java/xdroid/options/OptionAccessor.java import android.content.Context; import android.content.SharedPreferences; import java.util.Collections; import java.util.HashSet; import java.util.Set; import static xdroid.core.Global.getContext; import static xdroid.core.ObjectUtils.cast; import static xdroid.core.ObjectUtils.notNull; import static xdroid.core.SharedPreferencesUtils.getBoolean; import static xdroid.core.SharedPreferencesUtils.getFloat; import static xdroid.core.SharedPreferencesUtils.getInt; import static xdroid.core.SharedPreferencesUtils.getLong; import static xdroid.core.SharedPreferencesUtils.getString; import static xdroid.core.SharedPreferencesUtils.getStringSet; throw new UnsupportedOperationException(); } public boolean asStringSet(Set<String> value) { throw new UnsupportedOperationException(); } } protected class IntGetter extends Getter { public int asInt() { if (mValue == null) { mValue = getInt(getPrefs(), mOption.getName(), (Integer) mDefaultValue); } return (Integer) mValue; } } protected class IntSetter extends Setter { public boolean asInt(int value) { boolean changed = isChanged(mValue, value); mValue = value; getPrefs().edit().putInt(mOption.getName(), value).apply(); return changed; } } protected class LongGetter extends Getter { public long asLong() { if (mValue == null) {
mValue = getLong(getPrefs(), mOption.getName(), (Long) mDefaultValue);
shamanland/xdroid
lib-options/src/main/java/xdroid/options/OptionAccessor.java
// Path: lib-core/src/main/java/xdroid/core/Global.java // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // @SuppressWarnings("unchecked") // public static <T> T cast(Object object) { // return (T) object; // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static boolean getBoolean(SharedPreferences prefs, String key, boolean defaultValue) { // try { // return prefs.getBoolean(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static float getFloat(SharedPreferences prefs, String key, float defaultValue) { // try { // return prefs.getFloat(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static int getInt(SharedPreferences prefs, String key, int defaultValue) { // try { // return prefs.getInt(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static long getLong(SharedPreferences prefs, String key, long defaultValue) { // try { // return prefs.getLong(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static String getString(SharedPreferences prefs, String key, String defaultValue) { // try { // return prefs.getString(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static Set<String> getStringSet(SharedPreferences prefs, String key, Set<String> defaultValue) { // try { // return prefs.getStringSet(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // }
import android.content.Context; import android.content.SharedPreferences; import java.util.Collections; import java.util.HashSet; import java.util.Set; import static xdroid.core.Global.getContext; import static xdroid.core.ObjectUtils.cast; import static xdroid.core.ObjectUtils.notNull; import static xdroid.core.SharedPreferencesUtils.getBoolean; import static xdroid.core.SharedPreferencesUtils.getFloat; import static xdroid.core.SharedPreferencesUtils.getInt; import static xdroid.core.SharedPreferencesUtils.getLong; import static xdroid.core.SharedPreferencesUtils.getString; import static xdroid.core.SharedPreferencesUtils.getStringSet;
public boolean asInt(int value) { boolean changed = isChanged(mValue, value); mValue = value; getPrefs().edit().putInt(mOption.getName(), value).apply(); return changed; } } protected class LongGetter extends Getter { public long asLong() { if (mValue == null) { mValue = getLong(getPrefs(), mOption.getName(), (Long) mDefaultValue); } return (Long) mValue; } } protected class LongSetter extends Setter { public boolean asLong(long value) { boolean changed = isChanged(mValue, value); mValue = value; getPrefs().edit().putLong(mOption.getName(), value).apply(); return changed; } } protected class FloatGetter extends Getter { public float asFloat() { if (mValue == null) {
// Path: lib-core/src/main/java/xdroid/core/Global.java // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // @SuppressWarnings("unchecked") // public static <T> T cast(Object object) { // return (T) object; // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static boolean getBoolean(SharedPreferences prefs, String key, boolean defaultValue) { // try { // return prefs.getBoolean(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static float getFloat(SharedPreferences prefs, String key, float defaultValue) { // try { // return prefs.getFloat(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static int getInt(SharedPreferences prefs, String key, int defaultValue) { // try { // return prefs.getInt(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static long getLong(SharedPreferences prefs, String key, long defaultValue) { // try { // return prefs.getLong(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static String getString(SharedPreferences prefs, String key, String defaultValue) { // try { // return prefs.getString(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static Set<String> getStringSet(SharedPreferences prefs, String key, Set<String> defaultValue) { // try { // return prefs.getStringSet(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // Path: lib-options/src/main/java/xdroid/options/OptionAccessor.java import android.content.Context; import android.content.SharedPreferences; import java.util.Collections; import java.util.HashSet; import java.util.Set; import static xdroid.core.Global.getContext; import static xdroid.core.ObjectUtils.cast; import static xdroid.core.ObjectUtils.notNull; import static xdroid.core.SharedPreferencesUtils.getBoolean; import static xdroid.core.SharedPreferencesUtils.getFloat; import static xdroid.core.SharedPreferencesUtils.getInt; import static xdroid.core.SharedPreferencesUtils.getLong; import static xdroid.core.SharedPreferencesUtils.getString; import static xdroid.core.SharedPreferencesUtils.getStringSet; public boolean asInt(int value) { boolean changed = isChanged(mValue, value); mValue = value; getPrefs().edit().putInt(mOption.getName(), value).apply(); return changed; } } protected class LongGetter extends Getter { public long asLong() { if (mValue == null) { mValue = getLong(getPrefs(), mOption.getName(), (Long) mDefaultValue); } return (Long) mValue; } } protected class LongSetter extends Setter { public boolean asLong(long value) { boolean changed = isChanged(mValue, value); mValue = value; getPrefs().edit().putLong(mOption.getName(), value).apply(); return changed; } } protected class FloatGetter extends Getter { public float asFloat() { if (mValue == null) {
mValue = getFloat(getPrefs(), mOption.getName(), (Float) mDefaultValue);
shamanland/xdroid
lib-options/src/main/java/xdroid/options/OptionAccessor.java
// Path: lib-core/src/main/java/xdroid/core/Global.java // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // @SuppressWarnings("unchecked") // public static <T> T cast(Object object) { // return (T) object; // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static boolean getBoolean(SharedPreferences prefs, String key, boolean defaultValue) { // try { // return prefs.getBoolean(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static float getFloat(SharedPreferences prefs, String key, float defaultValue) { // try { // return prefs.getFloat(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static int getInt(SharedPreferences prefs, String key, int defaultValue) { // try { // return prefs.getInt(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static long getLong(SharedPreferences prefs, String key, long defaultValue) { // try { // return prefs.getLong(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static String getString(SharedPreferences prefs, String key, String defaultValue) { // try { // return prefs.getString(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static Set<String> getStringSet(SharedPreferences prefs, String key, Set<String> defaultValue) { // try { // return prefs.getStringSet(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // }
import android.content.Context; import android.content.SharedPreferences; import java.util.Collections; import java.util.HashSet; import java.util.Set; import static xdroid.core.Global.getContext; import static xdroid.core.ObjectUtils.cast; import static xdroid.core.ObjectUtils.notNull; import static xdroid.core.SharedPreferencesUtils.getBoolean; import static xdroid.core.SharedPreferencesUtils.getFloat; import static xdroid.core.SharedPreferencesUtils.getInt; import static xdroid.core.SharedPreferencesUtils.getLong; import static xdroid.core.SharedPreferencesUtils.getString; import static xdroid.core.SharedPreferencesUtils.getStringSet;
public boolean asLong(long value) { boolean changed = isChanged(mValue, value); mValue = value; getPrefs().edit().putLong(mOption.getName(), value).apply(); return changed; } } protected class FloatGetter extends Getter { public float asFloat() { if (mValue == null) { mValue = getFloat(getPrefs(), mOption.getName(), (Float) mDefaultValue); } return (Float) mValue; } } protected class FloatSetter extends Setter { public boolean asFloat(float value) { boolean changed = isChanged(mValue, value); mValue = value; getPrefs().edit().putFloat(mOption.getName(), value).apply(); return changed; } } protected class BooleanGetter extends Getter { public boolean asBoolean() { if (mValue == null) {
// Path: lib-core/src/main/java/xdroid/core/Global.java // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // @SuppressWarnings("unchecked") // public static <T> T cast(Object object) { // return (T) object; // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static boolean getBoolean(SharedPreferences prefs, String key, boolean defaultValue) { // try { // return prefs.getBoolean(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static float getFloat(SharedPreferences prefs, String key, float defaultValue) { // try { // return prefs.getFloat(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static int getInt(SharedPreferences prefs, String key, int defaultValue) { // try { // return prefs.getInt(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static long getLong(SharedPreferences prefs, String key, long defaultValue) { // try { // return prefs.getLong(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static String getString(SharedPreferences prefs, String key, String defaultValue) { // try { // return prefs.getString(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static Set<String> getStringSet(SharedPreferences prefs, String key, Set<String> defaultValue) { // try { // return prefs.getStringSet(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // Path: lib-options/src/main/java/xdroid/options/OptionAccessor.java import android.content.Context; import android.content.SharedPreferences; import java.util.Collections; import java.util.HashSet; import java.util.Set; import static xdroid.core.Global.getContext; import static xdroid.core.ObjectUtils.cast; import static xdroid.core.ObjectUtils.notNull; import static xdroid.core.SharedPreferencesUtils.getBoolean; import static xdroid.core.SharedPreferencesUtils.getFloat; import static xdroid.core.SharedPreferencesUtils.getInt; import static xdroid.core.SharedPreferencesUtils.getLong; import static xdroid.core.SharedPreferencesUtils.getString; import static xdroid.core.SharedPreferencesUtils.getStringSet; public boolean asLong(long value) { boolean changed = isChanged(mValue, value); mValue = value; getPrefs().edit().putLong(mOption.getName(), value).apply(); return changed; } } protected class FloatGetter extends Getter { public float asFloat() { if (mValue == null) { mValue = getFloat(getPrefs(), mOption.getName(), (Float) mDefaultValue); } return (Float) mValue; } } protected class FloatSetter extends Setter { public boolean asFloat(float value) { boolean changed = isChanged(mValue, value); mValue = value; getPrefs().edit().putFloat(mOption.getName(), value).apply(); return changed; } } protected class BooleanGetter extends Getter { public boolean asBoolean() { if (mValue == null) {
mValue = getBoolean(getPrefs(), mOption.getName(), (Boolean) mDefaultValue);
shamanland/xdroid
lib-options/src/main/java/xdroid/options/OptionAccessor.java
// Path: lib-core/src/main/java/xdroid/core/Global.java // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // @SuppressWarnings("unchecked") // public static <T> T cast(Object object) { // return (T) object; // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static boolean getBoolean(SharedPreferences prefs, String key, boolean defaultValue) { // try { // return prefs.getBoolean(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static float getFloat(SharedPreferences prefs, String key, float defaultValue) { // try { // return prefs.getFloat(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static int getInt(SharedPreferences prefs, String key, int defaultValue) { // try { // return prefs.getInt(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static long getLong(SharedPreferences prefs, String key, long defaultValue) { // try { // return prefs.getLong(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static String getString(SharedPreferences prefs, String key, String defaultValue) { // try { // return prefs.getString(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static Set<String> getStringSet(SharedPreferences prefs, String key, Set<String> defaultValue) { // try { // return prefs.getStringSet(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // }
import android.content.Context; import android.content.SharedPreferences; import java.util.Collections; import java.util.HashSet; import java.util.Set; import static xdroid.core.Global.getContext; import static xdroid.core.ObjectUtils.cast; import static xdroid.core.ObjectUtils.notNull; import static xdroid.core.SharedPreferencesUtils.getBoolean; import static xdroid.core.SharedPreferencesUtils.getFloat; import static xdroid.core.SharedPreferencesUtils.getInt; import static xdroid.core.SharedPreferencesUtils.getLong; import static xdroid.core.SharedPreferencesUtils.getString; import static xdroid.core.SharedPreferencesUtils.getStringSet;
public boolean asFloat(float value) { boolean changed = isChanged(mValue, value); mValue = value; getPrefs().edit().putFloat(mOption.getName(), value).apply(); return changed; } } protected class BooleanGetter extends Getter { public boolean asBoolean() { if (mValue == null) { mValue = getBoolean(getPrefs(), mOption.getName(), (Boolean) mDefaultValue); } return (Boolean) mValue; } } protected class BooleanSetter extends Setter { public boolean asBoolean(boolean value) { boolean changed = isChanged(mValue, value); mValue = value; getPrefs().edit().putBoolean(mOption.getName(), value).apply(); return changed; } } protected class StringGetter extends Getter { public String asString() { if (mValue == null) {
// Path: lib-core/src/main/java/xdroid/core/Global.java // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // @SuppressWarnings("unchecked") // public static <T> T cast(Object object) { // return (T) object; // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static boolean getBoolean(SharedPreferences prefs, String key, boolean defaultValue) { // try { // return prefs.getBoolean(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static float getFloat(SharedPreferences prefs, String key, float defaultValue) { // try { // return prefs.getFloat(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static int getInt(SharedPreferences prefs, String key, int defaultValue) { // try { // return prefs.getInt(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static long getLong(SharedPreferences prefs, String key, long defaultValue) { // try { // return prefs.getLong(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static String getString(SharedPreferences prefs, String key, String defaultValue) { // try { // return prefs.getString(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static Set<String> getStringSet(SharedPreferences prefs, String key, Set<String> defaultValue) { // try { // return prefs.getStringSet(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // Path: lib-options/src/main/java/xdroid/options/OptionAccessor.java import android.content.Context; import android.content.SharedPreferences; import java.util.Collections; import java.util.HashSet; import java.util.Set; import static xdroid.core.Global.getContext; import static xdroid.core.ObjectUtils.cast; import static xdroid.core.ObjectUtils.notNull; import static xdroid.core.SharedPreferencesUtils.getBoolean; import static xdroid.core.SharedPreferencesUtils.getFloat; import static xdroid.core.SharedPreferencesUtils.getInt; import static xdroid.core.SharedPreferencesUtils.getLong; import static xdroid.core.SharedPreferencesUtils.getString; import static xdroid.core.SharedPreferencesUtils.getStringSet; public boolean asFloat(float value) { boolean changed = isChanged(mValue, value); mValue = value; getPrefs().edit().putFloat(mOption.getName(), value).apply(); return changed; } } protected class BooleanGetter extends Getter { public boolean asBoolean() { if (mValue == null) { mValue = getBoolean(getPrefs(), mOption.getName(), (Boolean) mDefaultValue); } return (Boolean) mValue; } } protected class BooleanSetter extends Setter { public boolean asBoolean(boolean value) { boolean changed = isChanged(mValue, value); mValue = value; getPrefs().edit().putBoolean(mOption.getName(), value).apply(); return changed; } } protected class StringGetter extends Getter { public String asString() { if (mValue == null) {
mValue = getString(getPrefs(), mOption.getName(), (String) mDefaultValue);
shamanland/xdroid
lib-options/src/main/java/xdroid/options/OptionAccessor.java
// Path: lib-core/src/main/java/xdroid/core/Global.java // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // @SuppressWarnings("unchecked") // public static <T> T cast(Object object) { // return (T) object; // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static boolean getBoolean(SharedPreferences prefs, String key, boolean defaultValue) { // try { // return prefs.getBoolean(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static float getFloat(SharedPreferences prefs, String key, float defaultValue) { // try { // return prefs.getFloat(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static int getInt(SharedPreferences prefs, String key, int defaultValue) { // try { // return prefs.getInt(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static long getLong(SharedPreferences prefs, String key, long defaultValue) { // try { // return prefs.getLong(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static String getString(SharedPreferences prefs, String key, String defaultValue) { // try { // return prefs.getString(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static Set<String> getStringSet(SharedPreferences prefs, String key, Set<String> defaultValue) { // try { // return prefs.getStringSet(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // }
import android.content.Context; import android.content.SharedPreferences; import java.util.Collections; import java.util.HashSet; import java.util.Set; import static xdroid.core.Global.getContext; import static xdroid.core.ObjectUtils.cast; import static xdroid.core.ObjectUtils.notNull; import static xdroid.core.SharedPreferencesUtils.getBoolean; import static xdroid.core.SharedPreferencesUtils.getFloat; import static xdroid.core.SharedPreferencesUtils.getInt; import static xdroid.core.SharedPreferencesUtils.getLong; import static xdroid.core.SharedPreferencesUtils.getString; import static xdroid.core.SharedPreferencesUtils.getStringSet;
public boolean asBoolean(boolean value) { boolean changed = isChanged(mValue, value); mValue = value; getPrefs().edit().putBoolean(mOption.getName(), value).apply(); return changed; } } protected class StringGetter extends Getter { public String asString() { if (mValue == null) { mValue = getString(getPrefs(), mOption.getName(), (String) mDefaultValue); } return (String) mValue; } } protected class StringSetter extends Setter { public boolean asString(String value) { boolean changed = isChanged(mValue, value); mValue = value; getPrefs().edit().putString(mOption.getName(), value).apply(); return changed; } } protected class StringSetGetter extends Getter { public Set<String> asStringSet() { if (mValue == null) {
// Path: lib-core/src/main/java/xdroid/core/Global.java // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // @SuppressWarnings("unchecked") // public static <T> T cast(Object object) { // return (T) object; // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static boolean getBoolean(SharedPreferences prefs, String key, boolean defaultValue) { // try { // return prefs.getBoolean(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static float getFloat(SharedPreferences prefs, String key, float defaultValue) { // try { // return prefs.getFloat(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static int getInt(SharedPreferences prefs, String key, int defaultValue) { // try { // return prefs.getInt(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static long getLong(SharedPreferences prefs, String key, long defaultValue) { // try { // return prefs.getLong(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static String getString(SharedPreferences prefs, String key, String defaultValue) { // try { // return prefs.getString(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static Set<String> getStringSet(SharedPreferences prefs, String key, Set<String> defaultValue) { // try { // return prefs.getStringSet(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // Path: lib-options/src/main/java/xdroid/options/OptionAccessor.java import android.content.Context; import android.content.SharedPreferences; import java.util.Collections; import java.util.HashSet; import java.util.Set; import static xdroid.core.Global.getContext; import static xdroid.core.ObjectUtils.cast; import static xdroid.core.ObjectUtils.notNull; import static xdroid.core.SharedPreferencesUtils.getBoolean; import static xdroid.core.SharedPreferencesUtils.getFloat; import static xdroid.core.SharedPreferencesUtils.getInt; import static xdroid.core.SharedPreferencesUtils.getLong; import static xdroid.core.SharedPreferencesUtils.getString; import static xdroid.core.SharedPreferencesUtils.getStringSet; public boolean asBoolean(boolean value) { boolean changed = isChanged(mValue, value); mValue = value; getPrefs().edit().putBoolean(mOption.getName(), value).apply(); return changed; } } protected class StringGetter extends Getter { public String asString() { if (mValue == null) { mValue = getString(getPrefs(), mOption.getName(), (String) mDefaultValue); } return (String) mValue; } } protected class StringSetter extends Setter { public boolean asString(String value) { boolean changed = isChanged(mValue, value); mValue = value; getPrefs().edit().putString(mOption.getName(), value).apply(); return changed; } } protected class StringSetGetter extends Getter { public Set<String> asStringSet() { if (mValue == null) {
Set<String> defaultValue = cast(mDefaultValue);
shamanland/xdroid
lib-options/src/main/java/xdroid/options/OptionAccessor.java
// Path: lib-core/src/main/java/xdroid/core/Global.java // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // @SuppressWarnings("unchecked") // public static <T> T cast(Object object) { // return (T) object; // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static boolean getBoolean(SharedPreferences prefs, String key, boolean defaultValue) { // try { // return prefs.getBoolean(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static float getFloat(SharedPreferences prefs, String key, float defaultValue) { // try { // return prefs.getFloat(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static int getInt(SharedPreferences prefs, String key, int defaultValue) { // try { // return prefs.getInt(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static long getLong(SharedPreferences prefs, String key, long defaultValue) { // try { // return prefs.getLong(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static String getString(SharedPreferences prefs, String key, String defaultValue) { // try { // return prefs.getString(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static Set<String> getStringSet(SharedPreferences prefs, String key, Set<String> defaultValue) { // try { // return prefs.getStringSet(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // }
import android.content.Context; import android.content.SharedPreferences; import java.util.Collections; import java.util.HashSet; import java.util.Set; import static xdroid.core.Global.getContext; import static xdroid.core.ObjectUtils.cast; import static xdroid.core.ObjectUtils.notNull; import static xdroid.core.SharedPreferencesUtils.getBoolean; import static xdroid.core.SharedPreferencesUtils.getFloat; import static xdroid.core.SharedPreferencesUtils.getInt; import static xdroid.core.SharedPreferencesUtils.getLong; import static xdroid.core.SharedPreferencesUtils.getString; import static xdroid.core.SharedPreferencesUtils.getStringSet;
boolean changed = isChanged(mValue, value); mValue = value; getPrefs().edit().putBoolean(mOption.getName(), value).apply(); return changed; } } protected class StringGetter extends Getter { public String asString() { if (mValue == null) { mValue = getString(getPrefs(), mOption.getName(), (String) mDefaultValue); } return (String) mValue; } } protected class StringSetter extends Setter { public boolean asString(String value) { boolean changed = isChanged(mValue, value); mValue = value; getPrefs().edit().putString(mOption.getName(), value).apply(); return changed; } } protected class StringSetGetter extends Getter { public Set<String> asStringSet() { if (mValue == null) { Set<String> defaultValue = cast(mDefaultValue);
// Path: lib-core/src/main/java/xdroid/core/Global.java // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // @SuppressWarnings("unchecked") // public static <T> T cast(Object object) { // return (T) object; // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static boolean getBoolean(SharedPreferences prefs, String key, boolean defaultValue) { // try { // return prefs.getBoolean(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static float getFloat(SharedPreferences prefs, String key, float defaultValue) { // try { // return prefs.getFloat(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static int getInt(SharedPreferences prefs, String key, int defaultValue) { // try { // return prefs.getInt(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static long getLong(SharedPreferences prefs, String key, long defaultValue) { // try { // return prefs.getLong(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static String getString(SharedPreferences prefs, String key, String defaultValue) { // try { // return prefs.getString(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // // Path: lib-core/src/main/java/xdroid/core/SharedPreferencesUtils.java // public static Set<String> getStringSet(SharedPreferences prefs, String key, Set<String> defaultValue) { // try { // return prefs.getStringSet(key, defaultValue); // } catch (Throwable ex) { // return defaultValue; // } // } // Path: lib-options/src/main/java/xdroid/options/OptionAccessor.java import android.content.Context; import android.content.SharedPreferences; import java.util.Collections; import java.util.HashSet; import java.util.Set; import static xdroid.core.Global.getContext; import static xdroid.core.ObjectUtils.cast; import static xdroid.core.ObjectUtils.notNull; import static xdroid.core.SharedPreferencesUtils.getBoolean; import static xdroid.core.SharedPreferencesUtils.getFloat; import static xdroid.core.SharedPreferencesUtils.getInt; import static xdroid.core.SharedPreferencesUtils.getLong; import static xdroid.core.SharedPreferencesUtils.getString; import static xdroid.core.SharedPreferencesUtils.getStringSet; boolean changed = isChanged(mValue, value); mValue = value; getPrefs().edit().putBoolean(mOption.getName(), value).apply(); return changed; } } protected class StringGetter extends Getter { public String asString() { if (mValue == null) { mValue = getString(getPrefs(), mOption.getName(), (String) mDefaultValue); } return (String) mValue; } } protected class StringSetter extends Setter { public boolean asString(String value) { boolean changed = isChanged(mValue, value); mValue = value; getPrefs().edit().putString(mOption.getName(), value).apply(); return changed; } } protected class StringSetGetter extends Getter { public Set<String> asStringSet() { if (mValue == null) { Set<String> defaultValue = cast(mDefaultValue);
mValue = getStringSet(getPrefs(), mOption.getName(), defaultValue);
shamanland/xdroid
lib-customservice/src/main/java/xdroid/customservice/CustomServices.java
// Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // }
import java.util.HashMap; import java.util.Map; import static xdroid.core.ObjectUtils.notNull;
package xdroid.customservice; public class CustomServices implements CustomServiceResolver { private final CustomServiceResolver mParentResolver; private final Map<String, Object> mCustomServices; public CustomServices(CustomServiceResolver parentResolver) { mParentResolver = parentResolver; mCustomServices = new HashMap<>(); } @Override public void putCustomService(String name, Object instance) {
// Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // } // Path: lib-customservice/src/main/java/xdroid/customservice/CustomServices.java import java.util.HashMap; import java.util.Map; import static xdroid.core.ObjectUtils.notNull; package xdroid.customservice; public class CustomServices implements CustomServiceResolver { private final CustomServiceResolver mParentResolver; private final Map<String, Object> mCustomServices; public CustomServices(CustomServiceResolver parentResolver) { mParentResolver = parentResolver; mCustomServices = new HashMap<>(); } @Override public void putCustomService(String name, Object instance) {
mCustomServices.put(notNull(name), instance);
shamanland/xdroid
lib-adapter/src/main/java/xdroid/adapter/AdapterX.java
// Path: lib-collections/src/main/java/xdroid/collections/Indexed.java // public interface Indexed<E> { // int size(); // // E get(int location); // // E set(int location, E object); // } // // Path: lib-collections/src/main/java/xdroid/collections/IndexedIterator.java // public class IndexedIterator<E> implements Iterator<E> { // private final Indexed<E> mIndexed; // private int mCursor; // // public IndexedIterator(Indexed<E> indexed) { // mIndexed = notNull(indexed); // mCursor = -1; // } // // @Override // public boolean hasNext() { // return mCursor + 1 < mIndexed.size(); // } // // @Override // public E next() { // return mIndexed.get(++mCursor); // } // // @Override // public void remove() { // throw new UnsupportedOperationException(); // } // } // // Path: lib-core/src/main/java/xdroid/core/ParcelUtils.java // public final class ParcelUtils { // public static final int VAL_PARCELABLE = 0x01; // public static final int VAL_SERIALIZABLE = 0x02; // public static final int VAL_NULL = 0x03; // // private ParcelUtils() { // // disallow public access // } // // public static void writeParcelableOrSerializable(Parcel out, int flags, Object value) { // if (value instanceof Parcelable) { // out.writeInt(VAL_PARCELABLE); // out.writeParcelable((Parcelable) value, flags); // } else if (value instanceof Serializable) { // out.writeInt(VAL_SERIALIZABLE); // out.writeSerializable((Serializable) value); // } else { // out.writeInt(VAL_NULL); // } // } // // public static <T> T readParcelableOrSerializable(Parcel in, ClassLoader classLoader) { // switch (in.readInt()) { // case VAL_PARCELABLE: // //noinspection unchecked // return (T) in.readParcelable(classLoader); // // case VAL_SERIALIZABLE: // //noinspection unchecked // return (T) in.readSerializable(); // // case VAL_NULL: // // fall down // // default: // return null; // } // } // // public static void writeSparseIntArray(Parcel out, SparseIntArray value) { // if (value == null) { // out.writeInt(-1); // } else { // int count = value.size(); // out.writeInt(count); // // for (int i = 0; i < count; ++i) { // out.writeInt(value.keyAt(i)); // out.writeInt(value.valueAt(i)); // } // } // } // // public static SparseIntArray readSparseIntArray(Parcel in) { // int count = in.readInt(); // if (count < 0) { // return null; // } // // SparseIntArray result = new SparseIntArray(); // // for (int i = 0; i < count; ++i) { // int key = in.readInt(); // int value = in.readInt(); // // result.put(key, value); // } // // return result; // } // }
import android.os.Parcel; import android.os.Parcelable; import android.util.SparseIntArray; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import java.util.Iterator; import java.util.List; import xdroid.collections.Indexed; import xdroid.collections.IndexedIterator; import xdroid.core.ParcelUtils;
if (convertView == null) { result = (V) LayoutInflater.from(parent.getContext()).inflate(mLayoutId.get(getItemViewType(position)), parent, false); if (mBinder != null) { mBinder.onNewView(position, result); } } else { result = (V) convertView; } if (mBinder != null) { mBinder.onNewData(position, result, getItem(position)); } return result; } @SuppressWarnings("unused") public D getFirstItem() { return getCount() > 0 ? getItem(0) : null; } @SuppressWarnings("unused") public D getLastItem() { int count = getCount(); return count > 0 ? getItem(count - 1) : null; } @Override public Iterator<D> iterator() {
// Path: lib-collections/src/main/java/xdroid/collections/Indexed.java // public interface Indexed<E> { // int size(); // // E get(int location); // // E set(int location, E object); // } // // Path: lib-collections/src/main/java/xdroid/collections/IndexedIterator.java // public class IndexedIterator<E> implements Iterator<E> { // private final Indexed<E> mIndexed; // private int mCursor; // // public IndexedIterator(Indexed<E> indexed) { // mIndexed = notNull(indexed); // mCursor = -1; // } // // @Override // public boolean hasNext() { // return mCursor + 1 < mIndexed.size(); // } // // @Override // public E next() { // return mIndexed.get(++mCursor); // } // // @Override // public void remove() { // throw new UnsupportedOperationException(); // } // } // // Path: lib-core/src/main/java/xdroid/core/ParcelUtils.java // public final class ParcelUtils { // public static final int VAL_PARCELABLE = 0x01; // public static final int VAL_SERIALIZABLE = 0x02; // public static final int VAL_NULL = 0x03; // // private ParcelUtils() { // // disallow public access // } // // public static void writeParcelableOrSerializable(Parcel out, int flags, Object value) { // if (value instanceof Parcelable) { // out.writeInt(VAL_PARCELABLE); // out.writeParcelable((Parcelable) value, flags); // } else if (value instanceof Serializable) { // out.writeInt(VAL_SERIALIZABLE); // out.writeSerializable((Serializable) value); // } else { // out.writeInt(VAL_NULL); // } // } // // public static <T> T readParcelableOrSerializable(Parcel in, ClassLoader classLoader) { // switch (in.readInt()) { // case VAL_PARCELABLE: // //noinspection unchecked // return (T) in.readParcelable(classLoader); // // case VAL_SERIALIZABLE: // //noinspection unchecked // return (T) in.readSerializable(); // // case VAL_NULL: // // fall down // // default: // return null; // } // } // // public static void writeSparseIntArray(Parcel out, SparseIntArray value) { // if (value == null) { // out.writeInt(-1); // } else { // int count = value.size(); // out.writeInt(count); // // for (int i = 0; i < count; ++i) { // out.writeInt(value.keyAt(i)); // out.writeInt(value.valueAt(i)); // } // } // } // // public static SparseIntArray readSparseIntArray(Parcel in) { // int count = in.readInt(); // if (count < 0) { // return null; // } // // SparseIntArray result = new SparseIntArray(); // // for (int i = 0; i < count; ++i) { // int key = in.readInt(); // int value = in.readInt(); // // result.put(key, value); // } // // return result; // } // } // Path: lib-adapter/src/main/java/xdroid/adapter/AdapterX.java import android.os.Parcel; import android.os.Parcelable; import android.util.SparseIntArray; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import java.util.Iterator; import java.util.List; import xdroid.collections.Indexed; import xdroid.collections.IndexedIterator; import xdroid.core.ParcelUtils; if (convertView == null) { result = (V) LayoutInflater.from(parent.getContext()).inflate(mLayoutId.get(getItemViewType(position)), parent, false); if (mBinder != null) { mBinder.onNewView(position, result); } } else { result = (V) convertView; } if (mBinder != null) { mBinder.onNewData(position, result, getItem(position)); } return result; } @SuppressWarnings("unused") public D getFirstItem() { return getCount() > 0 ? getItem(0) : null; } @SuppressWarnings("unused") public D getLastItem() { int count = getCount(); return count > 0 ? getItem(count - 1) : null; } @Override public Iterator<D> iterator() {
return new IndexedIterator<D>(mData);
shamanland/xdroid
lib-adapter/src/main/java/xdroid/adapter/AdapterX.java
// Path: lib-collections/src/main/java/xdroid/collections/Indexed.java // public interface Indexed<E> { // int size(); // // E get(int location); // // E set(int location, E object); // } // // Path: lib-collections/src/main/java/xdroid/collections/IndexedIterator.java // public class IndexedIterator<E> implements Iterator<E> { // private final Indexed<E> mIndexed; // private int mCursor; // // public IndexedIterator(Indexed<E> indexed) { // mIndexed = notNull(indexed); // mCursor = -1; // } // // @Override // public boolean hasNext() { // return mCursor + 1 < mIndexed.size(); // } // // @Override // public E next() { // return mIndexed.get(++mCursor); // } // // @Override // public void remove() { // throw new UnsupportedOperationException(); // } // } // // Path: lib-core/src/main/java/xdroid/core/ParcelUtils.java // public final class ParcelUtils { // public static final int VAL_PARCELABLE = 0x01; // public static final int VAL_SERIALIZABLE = 0x02; // public static final int VAL_NULL = 0x03; // // private ParcelUtils() { // // disallow public access // } // // public static void writeParcelableOrSerializable(Parcel out, int flags, Object value) { // if (value instanceof Parcelable) { // out.writeInt(VAL_PARCELABLE); // out.writeParcelable((Parcelable) value, flags); // } else if (value instanceof Serializable) { // out.writeInt(VAL_SERIALIZABLE); // out.writeSerializable((Serializable) value); // } else { // out.writeInt(VAL_NULL); // } // } // // public static <T> T readParcelableOrSerializable(Parcel in, ClassLoader classLoader) { // switch (in.readInt()) { // case VAL_PARCELABLE: // //noinspection unchecked // return (T) in.readParcelable(classLoader); // // case VAL_SERIALIZABLE: // //noinspection unchecked // return (T) in.readSerializable(); // // case VAL_NULL: // // fall down // // default: // return null; // } // } // // public static void writeSparseIntArray(Parcel out, SparseIntArray value) { // if (value == null) { // out.writeInt(-1); // } else { // int count = value.size(); // out.writeInt(count); // // for (int i = 0; i < count; ++i) { // out.writeInt(value.keyAt(i)); // out.writeInt(value.valueAt(i)); // } // } // } // // public static SparseIntArray readSparseIntArray(Parcel in) { // int count = in.readInt(); // if (count < 0) { // return null; // } // // SparseIntArray result = new SparseIntArray(); // // for (int i = 0; i < count; ++i) { // int key = in.readInt(); // int value = in.readInt(); // // result.put(key, value); // } // // return result; // } // }
import android.os.Parcel; import android.os.Parcelable; import android.util.SparseIntArray; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import java.util.Iterator; import java.util.List; import xdroid.collections.Indexed; import xdroid.collections.IndexedIterator; import xdroid.core.ParcelUtils;
@SuppressWarnings("unused") public D getLastItem() { int count = getCount(); return count > 0 ? getItem(count - 1) : null; } @Override public Iterator<D> iterator() { return new IndexedIterator<D>(mData); } @Override public int getViewTypeCount() { return mLayoutId.size(); } @Override public int getItemViewType(int position) { if (mViewTypeResolver != null) { return mViewTypeResolver.getViewType(position, getItem(position)); } return super.getItemViewType(position); } public int describeContents() { return 0; } public void writeToParcel(Parcel out, int flags) {
// Path: lib-collections/src/main/java/xdroid/collections/Indexed.java // public interface Indexed<E> { // int size(); // // E get(int location); // // E set(int location, E object); // } // // Path: lib-collections/src/main/java/xdroid/collections/IndexedIterator.java // public class IndexedIterator<E> implements Iterator<E> { // private final Indexed<E> mIndexed; // private int mCursor; // // public IndexedIterator(Indexed<E> indexed) { // mIndexed = notNull(indexed); // mCursor = -1; // } // // @Override // public boolean hasNext() { // return mCursor + 1 < mIndexed.size(); // } // // @Override // public E next() { // return mIndexed.get(++mCursor); // } // // @Override // public void remove() { // throw new UnsupportedOperationException(); // } // } // // Path: lib-core/src/main/java/xdroid/core/ParcelUtils.java // public final class ParcelUtils { // public static final int VAL_PARCELABLE = 0x01; // public static final int VAL_SERIALIZABLE = 0x02; // public static final int VAL_NULL = 0x03; // // private ParcelUtils() { // // disallow public access // } // // public static void writeParcelableOrSerializable(Parcel out, int flags, Object value) { // if (value instanceof Parcelable) { // out.writeInt(VAL_PARCELABLE); // out.writeParcelable((Parcelable) value, flags); // } else if (value instanceof Serializable) { // out.writeInt(VAL_SERIALIZABLE); // out.writeSerializable((Serializable) value); // } else { // out.writeInt(VAL_NULL); // } // } // // public static <T> T readParcelableOrSerializable(Parcel in, ClassLoader classLoader) { // switch (in.readInt()) { // case VAL_PARCELABLE: // //noinspection unchecked // return (T) in.readParcelable(classLoader); // // case VAL_SERIALIZABLE: // //noinspection unchecked // return (T) in.readSerializable(); // // case VAL_NULL: // // fall down // // default: // return null; // } // } // // public static void writeSparseIntArray(Parcel out, SparseIntArray value) { // if (value == null) { // out.writeInt(-1); // } else { // int count = value.size(); // out.writeInt(count); // // for (int i = 0; i < count; ++i) { // out.writeInt(value.keyAt(i)); // out.writeInt(value.valueAt(i)); // } // } // } // // public static SparseIntArray readSparseIntArray(Parcel in) { // int count = in.readInt(); // if (count < 0) { // return null; // } // // SparseIntArray result = new SparseIntArray(); // // for (int i = 0; i < count; ++i) { // int key = in.readInt(); // int value = in.readInt(); // // result.put(key, value); // } // // return result; // } // } // Path: lib-adapter/src/main/java/xdroid/adapter/AdapterX.java import android.os.Parcel; import android.os.Parcelable; import android.util.SparseIntArray; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import java.util.Iterator; import java.util.List; import xdroid.collections.Indexed; import xdroid.collections.IndexedIterator; import xdroid.core.ParcelUtils; @SuppressWarnings("unused") public D getLastItem() { int count = getCount(); return count > 0 ? getItem(count - 1) : null; } @Override public Iterator<D> iterator() { return new IndexedIterator<D>(mData); } @Override public int getViewTypeCount() { return mLayoutId.size(); } @Override public int getItemViewType(int position) { if (mViewTypeResolver != null) { return mViewTypeResolver.getViewType(position, getItem(position)); } return super.getItemViewType(position); } public int describeContents() { return 0; } public void writeToParcel(Parcel out, int flags) {
ParcelUtils.writeParcelableOrSerializable(out, flags, mData);
shamanland/xdroid
lib-viewholder/src/main/java/xdroid/viewholder/ViewHolder.java
// Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // @SuppressWarnings("unchecked") // public static <T> T cast(Object object) { // return (T) object; // }
import android.util.SparseArray; import android.view.View; import static xdroid.core.ObjectUtils.cast;
package xdroid.viewholder; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ public final class ViewHolder { private static final Object NULL = new Object(); private final View mView; private final SparseArray<Object> mViews; private int mInt; private Object mObject; /** * Obtain instance based on passed <code>view</code>. * Newly created instance of <code>ViewHolder</code> will be saved as a tag for passed <code>view</code>. * Make sure the method {@link View#setTag(Object)} won't be invoked from other scopes. * @param view not null * @return not null */ public static ViewHolder obtain(View view) { if (view.getTag() instanceof ViewHolder) { return (ViewHolder) view.getTag(); } return new ViewHolder(view); } private ViewHolder(View view) { view.setTag(this); mView = view; mViews = new SparseArray<>(); } /** * Gets the saved <code>int</code>. * * @return previously saved value */ public int getInt() { return mInt; } /** * Sets the <code>int</code> value associated with this instance (e.g. position from <code>Adapter</code>). * * @param intValue value */ public void set(int intValue) { mInt = intValue; } /** * Gets the saved <code>Object</code>. * <b/> * NOTE: unchecked cast will be performed. * @param <T> any type return value to be casted to * @return previously saved instance */ public <T> T get() {
// Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // @SuppressWarnings("unchecked") // public static <T> T cast(Object object) { // return (T) object; // } // Path: lib-viewholder/src/main/java/xdroid/viewholder/ViewHolder.java import android.util.SparseArray; import android.view.View; import static xdroid.core.ObjectUtils.cast; package xdroid.viewholder; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ public final class ViewHolder { private static final Object NULL = new Object(); private final View mView; private final SparseArray<Object> mViews; private int mInt; private Object mObject; /** * Obtain instance based on passed <code>view</code>. * Newly created instance of <code>ViewHolder</code> will be saved as a tag for passed <code>view</code>. * Make sure the method {@link View#setTag(Object)} won't be invoked from other scopes. * @param view not null * @return not null */ public static ViewHolder obtain(View view) { if (view.getTag() instanceof ViewHolder) { return (ViewHolder) view.getTag(); } return new ViewHolder(view); } private ViewHolder(View view) { view.setTag(this); mView = view; mViews = new SparseArray<>(); } /** * Gets the saved <code>int</code>. * * @return previously saved value */ public int getInt() { return mInt; } /** * Sets the <code>int</code> value associated with this instance (e.g. position from <code>Adapter</code>). * * @param intValue value */ public void set(int intValue) { mInt = intValue; } /** * Gets the saved <code>Object</code>. * <b/> * NOTE: unchecked cast will be performed. * @param <T> any type return value to be casted to * @return previously saved instance */ public <T> T get() {
return cast(mObject);
shamanland/xdroid
lib-adapter/src/main/java/xdroid/adapter/CursorAdapterX.java
// Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // }
import android.content.Context; import android.database.Cursor; import android.util.SparseIntArray; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.CursorAdapter; import static xdroid.core.ObjectUtils.notNull;
public void setLayoutId(int layoutId) { putLayoutId(0, layoutId); } public void putLayoutId(int viewType, int layoutId) { mLayoutId.put(viewType, layoutId); notifyDataSetChanged(); } @SuppressWarnings("unused") public void lockChanges() { mChangesLocked = true; } @SuppressWarnings("unused") public void unlockChanges() { mChangesLocked = false; } @Override public void notifyDataSetChanged() { if (!mChangesLocked) { super.notifyDataSetChanged(); } } @Override @SuppressWarnings("unchecked") public V newView(Context context, Cursor cursor, ViewGroup parent) {
// Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // } // Path: lib-adapter/src/main/java/xdroid/adapter/CursorAdapterX.java import android.content.Context; import android.database.Cursor; import android.util.SparseIntArray; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.CursorAdapter; import static xdroid.core.ObjectUtils.notNull; public void setLayoutId(int layoutId) { putLayoutId(0, layoutId); } public void putLayoutId(int viewType, int layoutId) { mLayoutId.put(viewType, layoutId); notifyDataSetChanged(); } @SuppressWarnings("unused") public void lockChanges() { mChangesLocked = true; } @SuppressWarnings("unused") public void unlockChanges() { mChangesLocked = false; } @Override public void notifyDataSetChanged() { if (!mChangesLocked) { super.notifyDataSetChanged(); } } @Override @SuppressWarnings("unchecked") public V newView(Context context, Cursor cursor, ViewGroup parent) {
V result = (V) LayoutInflater.from(notNull(parent.getContext()))
shamanland/xdroid
app/src/main/java/xdroid/example/ExampleEnumFormatDialog.java
// Path: lib-enum-format/src/main/java/xdroid/enumformat/EnumFormat.java // public class EnumFormat extends Format { // private static final EnumFormat INSTANCE = new EnumFormat(); // // private Map<String, Integer> mCache; // // public static EnumFormat getInstance() { // return INSTANCE; // } // // public EnumFormat() { // mCache = new HashMap<>(); // } // // public synchronized void clearCache() { // mCache.clear(); // } // // protected synchronized Integer getCache(String fullName) { // return mCache.get(fullName); // } // // protected synchronized void putCache(String fullName, Integer value) { // mCache.put(fullName, value); // } // // /** // * Add annotations {@link EnumString} to each of your <code>enum</code> constants. // * If this annotation is not present, make sure you added corresponding <code>string</code> // * to <code>res</code> folder with the same name (lower case) as your <code>enum</code> constant. // * // * @param e not null // * @param <E> any enum type // * @return localized string if it was correctly configured // * @see EnumString // */ // public <E extends Enum<E>> String format(E e) { // return format((Object) e); // } // // @Override // @SuppressWarnings("NullableProblems") // public StringBuffer format(Object object, StringBuffer buffer, FieldPosition field) { // if (object instanceof Enum) { // Enum e = (Enum) object; // // int stringId = getStringId(e); // if (stringId != 0) { // buffer.append(getResources().getText(stringId)); // } else { // buffer.append(e.name()); // } // // return buffer; // } // // throw new IllegalArgumentException(String.valueOf(object)); // } // // protected int getStringId(Enum e) { // String fullName = e.getClass().getName() + "." + e.name(); // // Integer result = getCache(fullName); // if (result != null) { // return result; // } // // EnumString a = getAnnotation(e); // if (a != null) { // result = a.value(); // } else { // result = getResources().getIdentifier(e.name().toLowerCase(Locale.US), "string", getContext().getPackageName()); // } // // putCache(fullName, result); // return result; // } // // @Override // @SuppressWarnings("NullableProblems") // public Object parseObject(String string, ParsePosition position) { // throw new UnsupportedOperationException(); // } // // protected static EnumString getAnnotation(Enum e) { // try { // java.lang.reflect.Field field = e.getClass().getField(e.name()); // return field.getAnnotation(EnumString.class); // } catch (NoSuchFieldException ex) { // throw new AssertionError(ex); // } // } // }
import android.app.AlertDialog; import android.app.Dialog; import android.app.DialogFragment; import android.os.Bundle; import xdroid.enumformat.EnumFormat; import xdroid.enumformat.EnumString;
package xdroid.example; public class ExampleEnumFormatDialog extends DialogFragment { @Override public Dialog onCreateDialog(Bundle state) { MyEnum[] values = MyEnum.values(); CharSequence[] items = new CharSequence[values.length]; // use single instance
// Path: lib-enum-format/src/main/java/xdroid/enumformat/EnumFormat.java // public class EnumFormat extends Format { // private static final EnumFormat INSTANCE = new EnumFormat(); // // private Map<String, Integer> mCache; // // public static EnumFormat getInstance() { // return INSTANCE; // } // // public EnumFormat() { // mCache = new HashMap<>(); // } // // public synchronized void clearCache() { // mCache.clear(); // } // // protected synchronized Integer getCache(String fullName) { // return mCache.get(fullName); // } // // protected synchronized void putCache(String fullName, Integer value) { // mCache.put(fullName, value); // } // // /** // * Add annotations {@link EnumString} to each of your <code>enum</code> constants. // * If this annotation is not present, make sure you added corresponding <code>string</code> // * to <code>res</code> folder with the same name (lower case) as your <code>enum</code> constant. // * // * @param e not null // * @param <E> any enum type // * @return localized string if it was correctly configured // * @see EnumString // */ // public <E extends Enum<E>> String format(E e) { // return format((Object) e); // } // // @Override // @SuppressWarnings("NullableProblems") // public StringBuffer format(Object object, StringBuffer buffer, FieldPosition field) { // if (object instanceof Enum) { // Enum e = (Enum) object; // // int stringId = getStringId(e); // if (stringId != 0) { // buffer.append(getResources().getText(stringId)); // } else { // buffer.append(e.name()); // } // // return buffer; // } // // throw new IllegalArgumentException(String.valueOf(object)); // } // // protected int getStringId(Enum e) { // String fullName = e.getClass().getName() + "." + e.name(); // // Integer result = getCache(fullName); // if (result != null) { // return result; // } // // EnumString a = getAnnotation(e); // if (a != null) { // result = a.value(); // } else { // result = getResources().getIdentifier(e.name().toLowerCase(Locale.US), "string", getContext().getPackageName()); // } // // putCache(fullName, result); // return result; // } // // @Override // @SuppressWarnings("NullableProblems") // public Object parseObject(String string, ParsePosition position) { // throw new UnsupportedOperationException(); // } // // protected static EnumString getAnnotation(Enum e) { // try { // java.lang.reflect.Field field = e.getClass().getField(e.name()); // return field.getAnnotation(EnumString.class); // } catch (NoSuchFieldException ex) { // throw new AssertionError(ex); // } // } // } // Path: app/src/main/java/xdroid/example/ExampleEnumFormatDialog.java import android.app.AlertDialog; import android.app.Dialog; import android.app.DialogFragment; import android.os.Bundle; import xdroid.enumformat.EnumFormat; import xdroid.enumformat.EnumString; package xdroid.example; public class ExampleEnumFormatDialog extends DialogFragment { @Override public Dialog onCreateDialog(Bundle state) { MyEnum[] values = MyEnum.values(); CharSequence[] items = new CharSequence[values.length]; // use single instance
EnumFormat enumFormat = EnumFormat.getInstance();
shamanland/xdroid
app/src/main/java/xdroid/example/ExampleApplication.java
// Path: lib-app/src/main/java/xdroid/app/ApplicationX.java // public class ApplicationX extends Application implements ActivityStarter, ContextOwner { // @Override // public Context getContext() { // return this; // } // // @Override // public void startActivityForResult(Intent intent, int requestCode) { // startActivity(intent); // } // // @Override // protected void attachBaseContext(Context base) { // Global.setContext(this); // super.attachBaseContext(base); // } // } // // Path: lib-core/src/main/java/xdroid/core/Global.java // public final class Global { // private static Context sContext; // // private Global() { // // disallow public access // } // // public static void setContext(Context context) { // sContext = context; // } // // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // public static Resources getResources() { // return notNull(getContext().getResources()); // } // // public static Handler getUiHandler() { // return UiHandlerHolder.INSTANCE; // } // // public static Handler getBackgroundHandler() { // return BackgroundHandlerHolder.INSTANCE; // } // // static class CurrentApplicationHolder { // static final Application INSTANCE; // // static { // try { // Class<?> clazz = Class.forName("android.app.ActivityThread"); // Method method = ReflectUtils.getMethod(clazz, "currentApplication"); // INSTANCE = cast(ReflectUtils.invokeStaticMethod(method)); // } catch (Throwable ex) { // throw new AssertionError(ex); // } // } // } // // static class UiHandlerHolder { // static final Handler INSTANCE = new Handler(Looper.getMainLooper()); // } // // static class BackgroundHandlerHolder { // static final Handler INSTANCE = ThreadUtils.newThread(Global.class.getSimpleName(), null); // } // } // // Path: lib-core/src/main/java/xdroid/core/Singletons.java // public static <T> void putSingleton(Class<T> clazz, T instance) { // if (!clazz.isInstance(instance)) { // throw new IllegalArgumentException(); // } // // Object old = MAP.get(clazz); // if (old != null) { // throw new IllegalStateException(); // } // // MAP.put(clazz, notNull(instance)); // } // // Path: lib-toaster/src/main/java/xdroid/toaster/Toaster.java // public static void toast(int stringId) { // sendMessage(getContext().getText(stringId), Toast.LENGTH_SHORT); // }
import xdroid.app.ApplicationX; import xdroid.core.Global; import static xdroid.core.Singletons.putSingleton; import static xdroid.toaster.Toaster.toast;
package xdroid.example; public class ExampleApplication extends ApplicationX { @Override public void onCreate() { super.onCreate();
// Path: lib-app/src/main/java/xdroid/app/ApplicationX.java // public class ApplicationX extends Application implements ActivityStarter, ContextOwner { // @Override // public Context getContext() { // return this; // } // // @Override // public void startActivityForResult(Intent intent, int requestCode) { // startActivity(intent); // } // // @Override // protected void attachBaseContext(Context base) { // Global.setContext(this); // super.attachBaseContext(base); // } // } // // Path: lib-core/src/main/java/xdroid/core/Global.java // public final class Global { // private static Context sContext; // // private Global() { // // disallow public access // } // // public static void setContext(Context context) { // sContext = context; // } // // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // public static Resources getResources() { // return notNull(getContext().getResources()); // } // // public static Handler getUiHandler() { // return UiHandlerHolder.INSTANCE; // } // // public static Handler getBackgroundHandler() { // return BackgroundHandlerHolder.INSTANCE; // } // // static class CurrentApplicationHolder { // static final Application INSTANCE; // // static { // try { // Class<?> clazz = Class.forName("android.app.ActivityThread"); // Method method = ReflectUtils.getMethod(clazz, "currentApplication"); // INSTANCE = cast(ReflectUtils.invokeStaticMethod(method)); // } catch (Throwable ex) { // throw new AssertionError(ex); // } // } // } // // static class UiHandlerHolder { // static final Handler INSTANCE = new Handler(Looper.getMainLooper()); // } // // static class BackgroundHandlerHolder { // static final Handler INSTANCE = ThreadUtils.newThread(Global.class.getSimpleName(), null); // } // } // // Path: lib-core/src/main/java/xdroid/core/Singletons.java // public static <T> void putSingleton(Class<T> clazz, T instance) { // if (!clazz.isInstance(instance)) { // throw new IllegalArgumentException(); // } // // Object old = MAP.get(clazz); // if (old != null) { // throw new IllegalStateException(); // } // // MAP.put(clazz, notNull(instance)); // } // // Path: lib-toaster/src/main/java/xdroid/toaster/Toaster.java // public static void toast(int stringId) { // sendMessage(getContext().getText(stringId), Toast.LENGTH_SHORT); // } // Path: app/src/main/java/xdroid/example/ExampleApplication.java import xdroid.app.ApplicationX; import xdroid.core.Global; import static xdroid.core.Singletons.putSingleton; import static xdroid.toaster.Toaster.toast; package xdroid.example; public class ExampleApplication extends ApplicationX { @Override public void onCreate() { super.onCreate();
putSingleton(ExampleSingleton.class, new ExampleSingleton(this, R.string.app_name));
shamanland/xdroid
app/src/main/java/xdroid/example/ExampleApplication.java
// Path: lib-app/src/main/java/xdroid/app/ApplicationX.java // public class ApplicationX extends Application implements ActivityStarter, ContextOwner { // @Override // public Context getContext() { // return this; // } // // @Override // public void startActivityForResult(Intent intent, int requestCode) { // startActivity(intent); // } // // @Override // protected void attachBaseContext(Context base) { // Global.setContext(this); // super.attachBaseContext(base); // } // } // // Path: lib-core/src/main/java/xdroid/core/Global.java // public final class Global { // private static Context sContext; // // private Global() { // // disallow public access // } // // public static void setContext(Context context) { // sContext = context; // } // // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // public static Resources getResources() { // return notNull(getContext().getResources()); // } // // public static Handler getUiHandler() { // return UiHandlerHolder.INSTANCE; // } // // public static Handler getBackgroundHandler() { // return BackgroundHandlerHolder.INSTANCE; // } // // static class CurrentApplicationHolder { // static final Application INSTANCE; // // static { // try { // Class<?> clazz = Class.forName("android.app.ActivityThread"); // Method method = ReflectUtils.getMethod(clazz, "currentApplication"); // INSTANCE = cast(ReflectUtils.invokeStaticMethod(method)); // } catch (Throwable ex) { // throw new AssertionError(ex); // } // } // } // // static class UiHandlerHolder { // static final Handler INSTANCE = new Handler(Looper.getMainLooper()); // } // // static class BackgroundHandlerHolder { // static final Handler INSTANCE = ThreadUtils.newThread(Global.class.getSimpleName(), null); // } // } // // Path: lib-core/src/main/java/xdroid/core/Singletons.java // public static <T> void putSingleton(Class<T> clazz, T instance) { // if (!clazz.isInstance(instance)) { // throw new IllegalArgumentException(); // } // // Object old = MAP.get(clazz); // if (old != null) { // throw new IllegalStateException(); // } // // MAP.put(clazz, notNull(instance)); // } // // Path: lib-toaster/src/main/java/xdroid/toaster/Toaster.java // public static void toast(int stringId) { // sendMessage(getContext().getText(stringId), Toast.LENGTH_SHORT); // }
import xdroid.app.ApplicationX; import xdroid.core.Global; import static xdroid.core.Singletons.putSingleton; import static xdroid.toaster.Toaster.toast;
package xdroid.example; public class ExampleApplication extends ApplicationX { @Override public void onCreate() { super.onCreate(); putSingleton(ExampleSingleton.class, new ExampleSingleton(this, R.string.app_name));
// Path: lib-app/src/main/java/xdroid/app/ApplicationX.java // public class ApplicationX extends Application implements ActivityStarter, ContextOwner { // @Override // public Context getContext() { // return this; // } // // @Override // public void startActivityForResult(Intent intent, int requestCode) { // startActivity(intent); // } // // @Override // protected void attachBaseContext(Context base) { // Global.setContext(this); // super.attachBaseContext(base); // } // } // // Path: lib-core/src/main/java/xdroid/core/Global.java // public final class Global { // private static Context sContext; // // private Global() { // // disallow public access // } // // public static void setContext(Context context) { // sContext = context; // } // // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // public static Resources getResources() { // return notNull(getContext().getResources()); // } // // public static Handler getUiHandler() { // return UiHandlerHolder.INSTANCE; // } // // public static Handler getBackgroundHandler() { // return BackgroundHandlerHolder.INSTANCE; // } // // static class CurrentApplicationHolder { // static final Application INSTANCE; // // static { // try { // Class<?> clazz = Class.forName("android.app.ActivityThread"); // Method method = ReflectUtils.getMethod(clazz, "currentApplication"); // INSTANCE = cast(ReflectUtils.invokeStaticMethod(method)); // } catch (Throwable ex) { // throw new AssertionError(ex); // } // } // } // // static class UiHandlerHolder { // static final Handler INSTANCE = new Handler(Looper.getMainLooper()); // } // // static class BackgroundHandlerHolder { // static final Handler INSTANCE = ThreadUtils.newThread(Global.class.getSimpleName(), null); // } // } // // Path: lib-core/src/main/java/xdroid/core/Singletons.java // public static <T> void putSingleton(Class<T> clazz, T instance) { // if (!clazz.isInstance(instance)) { // throw new IllegalArgumentException(); // } // // Object old = MAP.get(clazz); // if (old != null) { // throw new IllegalStateException(); // } // // MAP.put(clazz, notNull(instance)); // } // // Path: lib-toaster/src/main/java/xdroid/toaster/Toaster.java // public static void toast(int stringId) { // sendMessage(getContext().getText(stringId), Toast.LENGTH_SHORT); // } // Path: app/src/main/java/xdroid/example/ExampleApplication.java import xdroid.app.ApplicationX; import xdroid.core.Global; import static xdroid.core.Singletons.putSingleton; import static xdroid.toaster.Toaster.toast; package xdroid.example; public class ExampleApplication extends ApplicationX { @Override public void onCreate() { super.onCreate(); putSingleton(ExampleSingleton.class, new ExampleSingleton(this, R.string.app_name));
toast(Global.getContext().toString());
shamanland/xdroid
app/src/main/java/xdroid/example/ExampleApplication.java
// Path: lib-app/src/main/java/xdroid/app/ApplicationX.java // public class ApplicationX extends Application implements ActivityStarter, ContextOwner { // @Override // public Context getContext() { // return this; // } // // @Override // public void startActivityForResult(Intent intent, int requestCode) { // startActivity(intent); // } // // @Override // protected void attachBaseContext(Context base) { // Global.setContext(this); // super.attachBaseContext(base); // } // } // // Path: lib-core/src/main/java/xdroid/core/Global.java // public final class Global { // private static Context sContext; // // private Global() { // // disallow public access // } // // public static void setContext(Context context) { // sContext = context; // } // // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // public static Resources getResources() { // return notNull(getContext().getResources()); // } // // public static Handler getUiHandler() { // return UiHandlerHolder.INSTANCE; // } // // public static Handler getBackgroundHandler() { // return BackgroundHandlerHolder.INSTANCE; // } // // static class CurrentApplicationHolder { // static final Application INSTANCE; // // static { // try { // Class<?> clazz = Class.forName("android.app.ActivityThread"); // Method method = ReflectUtils.getMethod(clazz, "currentApplication"); // INSTANCE = cast(ReflectUtils.invokeStaticMethod(method)); // } catch (Throwable ex) { // throw new AssertionError(ex); // } // } // } // // static class UiHandlerHolder { // static final Handler INSTANCE = new Handler(Looper.getMainLooper()); // } // // static class BackgroundHandlerHolder { // static final Handler INSTANCE = ThreadUtils.newThread(Global.class.getSimpleName(), null); // } // } // // Path: lib-core/src/main/java/xdroid/core/Singletons.java // public static <T> void putSingleton(Class<T> clazz, T instance) { // if (!clazz.isInstance(instance)) { // throw new IllegalArgumentException(); // } // // Object old = MAP.get(clazz); // if (old != null) { // throw new IllegalStateException(); // } // // MAP.put(clazz, notNull(instance)); // } // // Path: lib-toaster/src/main/java/xdroid/toaster/Toaster.java // public static void toast(int stringId) { // sendMessage(getContext().getText(stringId), Toast.LENGTH_SHORT); // }
import xdroid.app.ApplicationX; import xdroid.core.Global; import static xdroid.core.Singletons.putSingleton; import static xdroid.toaster.Toaster.toast;
package xdroid.example; public class ExampleApplication extends ApplicationX { @Override public void onCreate() { super.onCreate(); putSingleton(ExampleSingleton.class, new ExampleSingleton(this, R.string.app_name));
// Path: lib-app/src/main/java/xdroid/app/ApplicationX.java // public class ApplicationX extends Application implements ActivityStarter, ContextOwner { // @Override // public Context getContext() { // return this; // } // // @Override // public void startActivityForResult(Intent intent, int requestCode) { // startActivity(intent); // } // // @Override // protected void attachBaseContext(Context base) { // Global.setContext(this); // super.attachBaseContext(base); // } // } // // Path: lib-core/src/main/java/xdroid/core/Global.java // public final class Global { // private static Context sContext; // // private Global() { // // disallow public access // } // // public static void setContext(Context context) { // sContext = context; // } // // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // public static Resources getResources() { // return notNull(getContext().getResources()); // } // // public static Handler getUiHandler() { // return UiHandlerHolder.INSTANCE; // } // // public static Handler getBackgroundHandler() { // return BackgroundHandlerHolder.INSTANCE; // } // // static class CurrentApplicationHolder { // static final Application INSTANCE; // // static { // try { // Class<?> clazz = Class.forName("android.app.ActivityThread"); // Method method = ReflectUtils.getMethod(clazz, "currentApplication"); // INSTANCE = cast(ReflectUtils.invokeStaticMethod(method)); // } catch (Throwable ex) { // throw new AssertionError(ex); // } // } // } // // static class UiHandlerHolder { // static final Handler INSTANCE = new Handler(Looper.getMainLooper()); // } // // static class BackgroundHandlerHolder { // static final Handler INSTANCE = ThreadUtils.newThread(Global.class.getSimpleName(), null); // } // } // // Path: lib-core/src/main/java/xdroid/core/Singletons.java // public static <T> void putSingleton(Class<T> clazz, T instance) { // if (!clazz.isInstance(instance)) { // throw new IllegalArgumentException(); // } // // Object old = MAP.get(clazz); // if (old != null) { // throw new IllegalStateException(); // } // // MAP.put(clazz, notNull(instance)); // } // // Path: lib-toaster/src/main/java/xdroid/toaster/Toaster.java // public static void toast(int stringId) { // sendMessage(getContext().getText(stringId), Toast.LENGTH_SHORT); // } // Path: app/src/main/java/xdroid/example/ExampleApplication.java import xdroid.app.ApplicationX; import xdroid.core.Global; import static xdroid.core.Singletons.putSingleton; import static xdroid.toaster.Toaster.toast; package xdroid.example; public class ExampleApplication extends ApplicationX { @Override public void onCreate() { super.onCreate(); putSingleton(ExampleSingleton.class, new ExampleSingleton(this, R.string.app_name));
toast(Global.getContext().toString());
shamanland/xdroid
lib-collections/src/main/java/xdroid/collections/ArrayCollection.java
// Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // }
import java.util.Collection; import java.util.Iterator; import static xdroid.core.ObjectUtils.notNull;
package xdroid.collections; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ public class ArrayCollection<E> implements Collection<E> { private final E[] mBase; public ArrayCollection(E[] base) {
// Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // } // Path: lib-collections/src/main/java/xdroid/collections/ArrayCollection.java import java.util.Collection; import java.util.Iterator; import static xdroid.core.ObjectUtils.notNull; package xdroid.collections; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ public class ArrayCollection<E> implements Collection<E> { private final E[] mBase; public ArrayCollection(E[] base) {
mBase = notNull(base);
shamanland/xdroid
lib-app/src/main/java/xdroid/app/ActivityListeners.java
// Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // }
import android.app.Activity; import java.util.ArrayList; import java.util.Collection; import static xdroid.core.ObjectUtils.notNull;
package xdroid.app; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ public class ActivityListeners { private Collection<OnBackPressedListener> mBackPressed; private Collection<OnFinishListener> mFinish; public void add(OnBackPressedListener listener) { if (mBackPressed == null) { mBackPressed = new ArrayList<>(2); }
// Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // } // Path: lib-app/src/main/java/xdroid/app/ActivityListeners.java import android.app.Activity; import java.util.ArrayList; import java.util.Collection; import static xdroid.core.ObjectUtils.notNull; package xdroid.app; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ public class ActivityListeners { private Collection<OnBackPressedListener> mBackPressed; private Collection<OnFinishListener> mFinish; public void add(OnBackPressedListener listener) { if (mBackPressed == null) { mBackPressed = new ArrayList<>(2); }
mBackPressed.add(notNull(listener));
shamanland/xdroid
lib-toaster/src/main/java/xdroid/toaster/Toaster.java
// Path: lib-core/src/main/java/xdroid/core/Global.java // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // Path: lib-core/src/main/java/xdroid/core/Global.java // public static Handler getUiHandler() { // return UiHandlerHolder.INSTANCE; // } // // Path: lib-core/src/main/java/xdroid/core/ThreadUtils.java // public static Handler newHandler(Handler original, Handler.Callback callback) { // return new Handler(original.getLooper(), callback); // }
import android.os.Handler; import android.os.Message; import android.widget.Toast; import static xdroid.core.Global.getContext; import static xdroid.core.Global.getUiHandler; import static xdroid.core.ThreadUtils.newHandler;
package xdroid.toaster; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ @SuppressWarnings("unused") public final class Toaster implements Handler.Callback {
// Path: lib-core/src/main/java/xdroid/core/Global.java // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // Path: lib-core/src/main/java/xdroid/core/Global.java // public static Handler getUiHandler() { // return UiHandlerHolder.INSTANCE; // } // // Path: lib-core/src/main/java/xdroid/core/ThreadUtils.java // public static Handler newHandler(Handler original, Handler.Callback callback) { // return new Handler(original.getLooper(), callback); // } // Path: lib-toaster/src/main/java/xdroid/toaster/Toaster.java import android.os.Handler; import android.os.Message; import android.widget.Toast; import static xdroid.core.Global.getContext; import static xdroid.core.Global.getUiHandler; import static xdroid.core.ThreadUtils.newHandler; package xdroid.toaster; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ @SuppressWarnings("unused") public final class Toaster implements Handler.Callback {
private static final Handler sHandler = newHandler(getUiHandler(), new Toaster());
shamanland/xdroid
lib-toaster/src/main/java/xdroid/toaster/Toaster.java
// Path: lib-core/src/main/java/xdroid/core/Global.java // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // Path: lib-core/src/main/java/xdroid/core/Global.java // public static Handler getUiHandler() { // return UiHandlerHolder.INSTANCE; // } // // Path: lib-core/src/main/java/xdroid/core/ThreadUtils.java // public static Handler newHandler(Handler original, Handler.Callback callback) { // return new Handler(original.getLooper(), callback); // }
import android.os.Handler; import android.os.Message; import android.widget.Toast; import static xdroid.core.Global.getContext; import static xdroid.core.Global.getUiHandler; import static xdroid.core.ThreadUtils.newHandler;
package xdroid.toaster; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ @SuppressWarnings("unused") public final class Toaster implements Handler.Callback {
// Path: lib-core/src/main/java/xdroid/core/Global.java // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // Path: lib-core/src/main/java/xdroid/core/Global.java // public static Handler getUiHandler() { // return UiHandlerHolder.INSTANCE; // } // // Path: lib-core/src/main/java/xdroid/core/ThreadUtils.java // public static Handler newHandler(Handler original, Handler.Callback callback) { // return new Handler(original.getLooper(), callback); // } // Path: lib-toaster/src/main/java/xdroid/toaster/Toaster.java import android.os.Handler; import android.os.Message; import android.widget.Toast; import static xdroid.core.Global.getContext; import static xdroid.core.Global.getUiHandler; import static xdroid.core.ThreadUtils.newHandler; package xdroid.toaster; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ @SuppressWarnings("unused") public final class Toaster implements Handler.Callback {
private static final Handler sHandler = newHandler(getUiHandler(), new Toaster());
shamanland/xdroid
lib-toaster/src/main/java/xdroid/toaster/Toaster.java
// Path: lib-core/src/main/java/xdroid/core/Global.java // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // Path: lib-core/src/main/java/xdroid/core/Global.java // public static Handler getUiHandler() { // return UiHandlerHolder.INSTANCE; // } // // Path: lib-core/src/main/java/xdroid/core/ThreadUtils.java // public static Handler newHandler(Handler original, Handler.Callback callback) { // return new Handler(original.getLooper(), callback); // }
import android.os.Handler; import android.os.Message; import android.widget.Toast; import static xdroid.core.Global.getContext; import static xdroid.core.Global.getUiHandler; import static xdroid.core.ThreadUtils.newHandler;
package xdroid.toaster; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ @SuppressWarnings("unused") public final class Toaster implements Handler.Callback { private static final Handler sHandler = newHandler(getUiHandler(), new Toaster()); private Toaster() { // disallow public access } @Override public boolean handleMessage(Message msg) {
// Path: lib-core/src/main/java/xdroid/core/Global.java // public static Context getContext() { // if (sContext == null) { // sContext = CurrentApplicationHolder.INSTANCE; // } // // return notNull(sContext); // } // // Path: lib-core/src/main/java/xdroid/core/Global.java // public static Handler getUiHandler() { // return UiHandlerHolder.INSTANCE; // } // // Path: lib-core/src/main/java/xdroid/core/ThreadUtils.java // public static Handler newHandler(Handler original, Handler.Callback callback) { // return new Handler(original.getLooper(), callback); // } // Path: lib-toaster/src/main/java/xdroid/toaster/Toaster.java import android.os.Handler; import android.os.Message; import android.widget.Toast; import static xdroid.core.Global.getContext; import static xdroid.core.Global.getUiHandler; import static xdroid.core.ThreadUtils.newHandler; package xdroid.toaster; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ @SuppressWarnings("unused") public final class Toaster implements Handler.Callback { private static final Handler sHandler = newHandler(getUiHandler(), new Toaster()); private Toaster() { // disallow public access } @Override public boolean handleMessage(Message msg) {
Toast.makeText(getContext(), (CharSequence) msg.obj, msg.what).show();
shamanland/xdroid
lib-collections/src/main/java/xdroid/collections/IndexedCollection.java
// Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // }
import java.util.Collection; import java.util.Iterator; import static xdroid.core.ObjectUtils.notNull;
package xdroid.collections; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ public class IndexedCollection<E> implements Collection<E> { private final Indexed<E> mBase; public IndexedCollection(Indexed<E> base) {
// Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // } // Path: lib-collections/src/main/java/xdroid/collections/IndexedCollection.java import java.util.Collection; import java.util.Iterator; import static xdroid.core.ObjectUtils.notNull; package xdroid.collections; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ public class IndexedCollection<E> implements Collection<E> { private final Indexed<E> mBase; public IndexedCollection(Indexed<E> base) {
mBase = notNull(base);
shamanland/xdroid
lib-core/src/main/java/xdroid/core/Global.java
// Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // @SuppressWarnings("unchecked") // public static <T> T cast(Object object) { // return (T) object; // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // }
import android.app.Application; import android.content.Context; import android.content.res.Resources; import android.os.Handler; import android.os.Looper; import java.lang.reflect.Method; import static xdroid.core.ObjectUtils.cast; import static xdroid.core.ObjectUtils.notNull;
package xdroid.core; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ public final class Global { private static Context sContext; private Global() { // disallow public access } public static void setContext(Context context) { sContext = context; } public static Context getContext() { if (sContext == null) { sContext = CurrentApplicationHolder.INSTANCE; }
// Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // @SuppressWarnings("unchecked") // public static <T> T cast(Object object) { // return (T) object; // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // } // Path: lib-core/src/main/java/xdroid/core/Global.java import android.app.Application; import android.content.Context; import android.content.res.Resources; import android.os.Handler; import android.os.Looper; import java.lang.reflect.Method; import static xdroid.core.ObjectUtils.cast; import static xdroid.core.ObjectUtils.notNull; package xdroid.core; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ public final class Global { private static Context sContext; private Global() { // disallow public access } public static void setContext(Context context) { sContext = context; } public static Context getContext() { if (sContext == null) { sContext = CurrentApplicationHolder.INSTANCE; }
return notNull(sContext);
shamanland/xdroid
lib-core/src/main/java/xdroid/core/Global.java
// Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // @SuppressWarnings("unchecked") // public static <T> T cast(Object object) { // return (T) object; // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // }
import android.app.Application; import android.content.Context; import android.content.res.Resources; import android.os.Handler; import android.os.Looper; import java.lang.reflect.Method; import static xdroid.core.ObjectUtils.cast; import static xdroid.core.ObjectUtils.notNull;
package xdroid.core; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ public final class Global { private static Context sContext; private Global() { // disallow public access } public static void setContext(Context context) { sContext = context; } public static Context getContext() { if (sContext == null) { sContext = CurrentApplicationHolder.INSTANCE; } return notNull(sContext); } public static Resources getResources() { return notNull(getContext().getResources()); } public static Handler getUiHandler() { return UiHandlerHolder.INSTANCE; } public static Handler getBackgroundHandler() { return BackgroundHandlerHolder.INSTANCE; } static class CurrentApplicationHolder { static final Application INSTANCE; static { try { Class<?> clazz = Class.forName("android.app.ActivityThread"); Method method = ReflectUtils.getMethod(clazz, "currentApplication");
// Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // @SuppressWarnings("unchecked") // public static <T> T cast(Object object) { // return (T) object; // } // // Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // } // Path: lib-core/src/main/java/xdroid/core/Global.java import android.app.Application; import android.content.Context; import android.content.res.Resources; import android.os.Handler; import android.os.Looper; import java.lang.reflect.Method; import static xdroid.core.ObjectUtils.cast; import static xdroid.core.ObjectUtils.notNull; package xdroid.core; /** * @author Oleksii Kropachov (o.kropachov@shamanland.com) */ public final class Global { private static Context sContext; private Global() { // disallow public access } public static void setContext(Context context) { sContext = context; } public static Context getContext() { if (sContext == null) { sContext = CurrentApplicationHolder.INSTANCE; } return notNull(sContext); } public static Resources getResources() { return notNull(getContext().getResources()); } public static Handler getUiHandler() { return UiHandlerHolder.INSTANCE; } public static Handler getBackgroundHandler() { return BackgroundHandlerHolder.INSTANCE; } static class CurrentApplicationHolder { static final Application INSTANCE; static { try { Class<?> clazz = Class.forName("android.app.ActivityThread"); Method method = ReflectUtils.getMethod(clazz, "currentApplication");
INSTANCE = cast(ReflectUtils.invokeStaticMethod(method));
shamanland/xdroid
lib-core/src/main/java/xdroid/core/Singletons.java
// Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // }
import java.util.HashMap; import java.util.Map; import static xdroid.core.ObjectUtils.notNull;
package xdroid.core; public final class Singletons { private static final Map<Class<?>, Object> MAP = new HashMap<>(); public static <T> void putSingleton(Class<T> clazz, T instance) { if (!clazz.isInstance(instance)) { throw new IllegalArgumentException(); } Object old = MAP.get(clazz); if (old != null) { throw new IllegalStateException(); }
// Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java // public static <T> T notNull(T object) { // if (object == null) { // throw new NullPointerException(); // } // // return object; // } // Path: lib-core/src/main/java/xdroid/core/Singletons.java import java.util.HashMap; import java.util.Map; import static xdroid.core.ObjectUtils.notNull; package xdroid.core; public final class Singletons { private static final Map<Class<?>, Object> MAP = new HashMap<>(); public static <T> void putSingleton(Class<T> clazz, T instance) { if (!clazz.isInstance(instance)) { throw new IllegalArgumentException(); } Object old = MAP.get(clazz); if (old != null) { throw new IllegalStateException(); }
MAP.put(clazz, notNull(instance));
HomeAdvisor/Robusto
robusto-spring/src/main/java/com/homeadvisor/robusto/spring/RestTemplateInvoker.java
// Path: robusto-core/src/main/java/com/homeadvisor/robusto/CommandContext.java // public interface CommandContext // { // /** // * Get the logical name. // * @return Logical command name. // */ // String getCommandName(); // // /** // * Looks up the value associated with the given key from the attributes. // * @param key Key to lookup in command data map. // * @return Value associated with the given key, or null if none was set. // */ // Object getCommandAttribute(String key); // // /** // * Sets the given key/value pair for the underlying command attributes. Will // * overwrite existing key if it exists. // * @param key Key name to use. // * @param val Value to associate with the key. // */ // void setCommandAttribute(String key, Object val); // // /** // * Removes the given key, if it exists, from the underlying command attributes. // * This is a no-op if the key doesn't exist. // * @param key Key to remove. // */ // void removeCommandAttribute(String key); // }
import com.homeadvisor.robusto.CommandContext; import org.springframework.web.client.RestTemplate;
package com.homeadvisor.robusto.spring; @FunctionalInterface public interface RestTemplateInvoker<T> {
// Path: robusto-core/src/main/java/com/homeadvisor/robusto/CommandContext.java // public interface CommandContext // { // /** // * Get the logical name. // * @return Logical command name. // */ // String getCommandName(); // // /** // * Looks up the value associated with the given key from the attributes. // * @param key Key to lookup in command data map. // * @return Value associated with the given key, or null if none was set. // */ // Object getCommandAttribute(String key); // // /** // * Sets the given key/value pair for the underlying command attributes. Will // * overwrite existing key if it exists. // * @param key Key name to use. // * @param val Value to associate with the key. // */ // void setCommandAttribute(String key, Object val); // // /** // * Removes the given key, if it exists, from the underlying command attributes. // * This is a no-op if the key doesn't exist. // * @param key Key to remove. // */ // void removeCommandAttribute(String key); // } // Path: robusto-spring/src/main/java/com/homeadvisor/robusto/spring/RestTemplateInvoker.java import com.homeadvisor.robusto.CommandContext; import org.springframework.web.client.RestTemplate; package com.homeadvisor.robusto.spring; @FunctionalInterface public interface RestTemplateInvoker<T> {
T run(CommandContext ctx, RestTemplate restTemplate, String url);
HomeAdvisor/Robusto
robusto-curator/src/main/java/com/homeadvisor/robusto/curator/health/CuratorHealthCheck.java
// Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/HealthCheck.java // public interface HealthCheck // { // /** // * Run the health check and return the result. // * @return Result of the health check. // */ // HealthCheckResult doCheck(); // } // // Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/HealthCheckResult.java // public class HealthCheckResult // { // /** // * State of the health check. // */ // public Status status = Status.HEALTHY; // // /** // * Optional description to elaborate on the status enum. // */ // public String description; // // /** // * Convenience constructor to set all required fields. // * @param status Status of the check. // */ // public HealthCheckResult(Status status) // { // this.status = status; // } // // /** // * Convenience constructor to set all fields. // * @param status Status of the check. // * @param description Optional descriptipn to elaborate on the status. // */ // public HealthCheckResult(Status status, String description) // { // this.status = status; // this.description = description; // } // } // // Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/Status.java // public enum Status // { // HEALTHY, // IMPAIRED, // UNHEALTHY, // UNKNOWN // }
import com.homeadvisor.robusto.health.HealthCheck; import com.homeadvisor.robusto.health.HealthCheckResult; import com.homeadvisor.robusto.health.Status; import org.apache.curator.x.discovery.ServiceProvider;
/* * Copyright 2016 HomeAdvisor, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.homeadvisor.robusto.curator.health; /** * Health check handler that bases health off of curator service discovery. * The health check reports down if there is not a minimum number of * available service instances. */ public class CuratorHealthCheck implements HealthCheck { /** * Curator service discovery interface used to look up service instances. */ private ServiceProvider serviceProvider; /** * The minimum number of service instances required for this health check * to report healthy. */ private int minNumberInstances; public CuratorHealthCheck(ServiceProvider serviceProvider, int minNumberInstances) { this.serviceProvider = serviceProvider; this.minNumberInstances = minNumberInstances; } @Override
// Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/HealthCheck.java // public interface HealthCheck // { // /** // * Run the health check and return the result. // * @return Result of the health check. // */ // HealthCheckResult doCheck(); // } // // Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/HealthCheckResult.java // public class HealthCheckResult // { // /** // * State of the health check. // */ // public Status status = Status.HEALTHY; // // /** // * Optional description to elaborate on the status enum. // */ // public String description; // // /** // * Convenience constructor to set all required fields. // * @param status Status of the check. // */ // public HealthCheckResult(Status status) // { // this.status = status; // } // // /** // * Convenience constructor to set all fields. // * @param status Status of the check. // * @param description Optional descriptipn to elaborate on the status. // */ // public HealthCheckResult(Status status, String description) // { // this.status = status; // this.description = description; // } // } // // Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/Status.java // public enum Status // { // HEALTHY, // IMPAIRED, // UNHEALTHY, // UNKNOWN // } // Path: robusto-curator/src/main/java/com/homeadvisor/robusto/curator/health/CuratorHealthCheck.java import com.homeadvisor.robusto.health.HealthCheck; import com.homeadvisor.robusto.health.HealthCheckResult; import com.homeadvisor.robusto.health.Status; import org.apache.curator.x.discovery.ServiceProvider; /* * Copyright 2016 HomeAdvisor, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.homeadvisor.robusto.curator.health; /** * Health check handler that bases health off of curator service discovery. * The health check reports down if there is not a minimum number of * available service instances. */ public class CuratorHealthCheck implements HealthCheck { /** * Curator service discovery interface used to look up service instances. */ private ServiceProvider serviceProvider; /** * The minimum number of service instances required for this health check * to report healthy. */ private int minNumberInstances; public CuratorHealthCheck(ServiceProvider serviceProvider, int minNumberInstances) { this.serviceProvider = serviceProvider; this.minNumberInstances = minNumberInstances; } @Override
public HealthCheckResult doCheck()
HomeAdvisor/Robusto
robusto-curator/src/main/java/com/homeadvisor/robusto/curator/health/CuratorHealthCheck.java
// Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/HealthCheck.java // public interface HealthCheck // { // /** // * Run the health check and return the result. // * @return Result of the health check. // */ // HealthCheckResult doCheck(); // } // // Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/HealthCheckResult.java // public class HealthCheckResult // { // /** // * State of the health check. // */ // public Status status = Status.HEALTHY; // // /** // * Optional description to elaborate on the status enum. // */ // public String description; // // /** // * Convenience constructor to set all required fields. // * @param status Status of the check. // */ // public HealthCheckResult(Status status) // { // this.status = status; // } // // /** // * Convenience constructor to set all fields. // * @param status Status of the check. // * @param description Optional descriptipn to elaborate on the status. // */ // public HealthCheckResult(Status status, String description) // { // this.status = status; // this.description = description; // } // } // // Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/Status.java // public enum Status // { // HEALTHY, // IMPAIRED, // UNHEALTHY, // UNKNOWN // }
import com.homeadvisor.robusto.health.HealthCheck; import com.homeadvisor.robusto.health.HealthCheckResult; import com.homeadvisor.robusto.health.Status; import org.apache.curator.x.discovery.ServiceProvider;
/* * Copyright 2016 HomeAdvisor, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.homeadvisor.robusto.curator.health; /** * Health check handler that bases health off of curator service discovery. * The health check reports down if there is not a minimum number of * available service instances. */ public class CuratorHealthCheck implements HealthCheck { /** * Curator service discovery interface used to look up service instances. */ private ServiceProvider serviceProvider; /** * The minimum number of service instances required for this health check * to report healthy. */ private int minNumberInstances; public CuratorHealthCheck(ServiceProvider serviceProvider, int minNumberInstances) { this.serviceProvider = serviceProvider; this.minNumberInstances = minNumberInstances; } @Override public HealthCheckResult doCheck() { try { int numInstances = serviceProvider.getAllInstances().size(); return numInstances >= minNumberInstances
// Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/HealthCheck.java // public interface HealthCheck // { // /** // * Run the health check and return the result. // * @return Result of the health check. // */ // HealthCheckResult doCheck(); // } // // Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/HealthCheckResult.java // public class HealthCheckResult // { // /** // * State of the health check. // */ // public Status status = Status.HEALTHY; // // /** // * Optional description to elaborate on the status enum. // */ // public String description; // // /** // * Convenience constructor to set all required fields. // * @param status Status of the check. // */ // public HealthCheckResult(Status status) // { // this.status = status; // } // // /** // * Convenience constructor to set all fields. // * @param status Status of the check. // * @param description Optional descriptipn to elaborate on the status. // */ // public HealthCheckResult(Status status, String description) // { // this.status = status; // this.description = description; // } // } // // Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/Status.java // public enum Status // { // HEALTHY, // IMPAIRED, // UNHEALTHY, // UNKNOWN // } // Path: robusto-curator/src/main/java/com/homeadvisor/robusto/curator/health/CuratorHealthCheck.java import com.homeadvisor.robusto.health.HealthCheck; import com.homeadvisor.robusto.health.HealthCheckResult; import com.homeadvisor.robusto.health.Status; import org.apache.curator.x.discovery.ServiceProvider; /* * Copyright 2016 HomeAdvisor, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.homeadvisor.robusto.curator.health; /** * Health check handler that bases health off of curator service discovery. * The health check reports down if there is not a minimum number of * available service instances. */ public class CuratorHealthCheck implements HealthCheck { /** * Curator service discovery interface used to look up service instances. */ private ServiceProvider serviceProvider; /** * The minimum number of service instances required for this health check * to report healthy. */ private int minNumberInstances; public CuratorHealthCheck(ServiceProvider serviceProvider, int minNumberInstances) { this.serviceProvider = serviceProvider; this.minNumberInstances = minNumberInstances; } @Override public HealthCheckResult doCheck() { try { int numInstances = serviceProvider.getAllInstances().size(); return numInstances >= minNumberInstances
? new HealthCheckResult(Status.HEALTHY)
HomeAdvisor/Robusto
robusto-codahale/src/main/java/com/homeadvisor/robusto/health/codahale/CodahaleClientHealthCheck.java
// Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/HealthCheckAwareClient.java // public interface HealthCheckAwareClient // { // /** // * List of healthchecks to execute to determine overall health. // */ // List<HealthCheck> checks = new ArrayList<>(); // // // // // Interface methods // // // // /** // * Add a new {@link HealthCheck} to be executed as part of the overall // * client health. HealthChecks will be executed in the order in which they // * are registered. // * @param check // */ // default void registerCheck(HealthCheck check) // { // checks.add(check); // } // // /** // * Main method for determining client health. Default implementation is to // * simply execute all registered handlers and combine them into a single // * list of results. // * @return List of individual results. // */ // default Map<String, HealthCheckResult> doAllChecks() // { // Map<String, HealthCheckResult> results = new TreeMap<>(); // // for(HealthCheck check : checks) // { // results.put(check.getClass().getSimpleName(), check.doCheck()); // } // // return results; // } // } // // Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/HealthCheckResult.java // public class HealthCheckResult // { // /** // * State of the health check. // */ // public Status status = Status.HEALTHY; // // /** // * Optional description to elaborate on the status enum. // */ // public String description; // // /** // * Convenience constructor to set all required fields. // * @param status Status of the check. // */ // public HealthCheckResult(Status status) // { // this.status = status; // } // // /** // * Convenience constructor to set all fields. // * @param status Status of the check. // * @param description Optional descriptipn to elaborate on the status. // */ // public HealthCheckResult(Status status, String description) // { // this.status = status; // this.description = description; // } // } // // Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/Status.java // public enum Status // { // HEALTHY, // IMPAIRED, // UNHEALTHY, // UNKNOWN // }
import com.codahale.metrics.health.HealthCheck; import com.homeadvisor.robusto.health.HealthCheckAwareClient; import com.homeadvisor.robusto.health.HealthCheckResult; import com.homeadvisor.robusto.health.Status; import java.util.Map;
/* * Copyright 2016 HomeAdvisor, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.homeadvisor.robusto.health.codahale; /** * Implementation of {@link HealthCheckAwareClient} that reports health using * Codahale's {@link HealthCheck}. */ public class CodahaleClientHealthCheck extends HealthCheck implements HealthCheckAwareClient { @Override protected Result check() { // // Get the parent results first // boolean isUnhealthy = false; StringBuilder msg = new StringBuilder(); try {
// Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/HealthCheckAwareClient.java // public interface HealthCheckAwareClient // { // /** // * List of healthchecks to execute to determine overall health. // */ // List<HealthCheck> checks = new ArrayList<>(); // // // // // Interface methods // // // // /** // * Add a new {@link HealthCheck} to be executed as part of the overall // * client health. HealthChecks will be executed in the order in which they // * are registered. // * @param check // */ // default void registerCheck(HealthCheck check) // { // checks.add(check); // } // // /** // * Main method for determining client health. Default implementation is to // * simply execute all registered handlers and combine them into a single // * list of results. // * @return List of individual results. // */ // default Map<String, HealthCheckResult> doAllChecks() // { // Map<String, HealthCheckResult> results = new TreeMap<>(); // // for(HealthCheck check : checks) // { // results.put(check.getClass().getSimpleName(), check.doCheck()); // } // // return results; // } // } // // Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/HealthCheckResult.java // public class HealthCheckResult // { // /** // * State of the health check. // */ // public Status status = Status.HEALTHY; // // /** // * Optional description to elaborate on the status enum. // */ // public String description; // // /** // * Convenience constructor to set all required fields. // * @param status Status of the check. // */ // public HealthCheckResult(Status status) // { // this.status = status; // } // // /** // * Convenience constructor to set all fields. // * @param status Status of the check. // * @param description Optional descriptipn to elaborate on the status. // */ // public HealthCheckResult(Status status, String description) // { // this.status = status; // this.description = description; // } // } // // Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/Status.java // public enum Status // { // HEALTHY, // IMPAIRED, // UNHEALTHY, // UNKNOWN // } // Path: robusto-codahale/src/main/java/com/homeadvisor/robusto/health/codahale/CodahaleClientHealthCheck.java import com.codahale.metrics.health.HealthCheck; import com.homeadvisor.robusto.health.HealthCheckAwareClient; import com.homeadvisor.robusto.health.HealthCheckResult; import com.homeadvisor.robusto.health.Status; import java.util.Map; /* * Copyright 2016 HomeAdvisor, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.homeadvisor.robusto.health.codahale; /** * Implementation of {@link HealthCheckAwareClient} that reports health using * Codahale's {@link HealthCheck}. */ public class CodahaleClientHealthCheck extends HealthCheck implements HealthCheckAwareClient { @Override protected Result check() { // // Get the parent results first // boolean isUnhealthy = false; StringBuilder msg = new StringBuilder(); try {
Map<String, HealthCheckResult> results = doAllChecks();
HomeAdvisor/Robusto
robusto-codahale/src/main/java/com/homeadvisor/robusto/health/codahale/CodahaleClientHealthCheck.java
// Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/HealthCheckAwareClient.java // public interface HealthCheckAwareClient // { // /** // * List of healthchecks to execute to determine overall health. // */ // List<HealthCheck> checks = new ArrayList<>(); // // // // // Interface methods // // // // /** // * Add a new {@link HealthCheck} to be executed as part of the overall // * client health. HealthChecks will be executed in the order in which they // * are registered. // * @param check // */ // default void registerCheck(HealthCheck check) // { // checks.add(check); // } // // /** // * Main method for determining client health. Default implementation is to // * simply execute all registered handlers and combine them into a single // * list of results. // * @return List of individual results. // */ // default Map<String, HealthCheckResult> doAllChecks() // { // Map<String, HealthCheckResult> results = new TreeMap<>(); // // for(HealthCheck check : checks) // { // results.put(check.getClass().getSimpleName(), check.doCheck()); // } // // return results; // } // } // // Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/HealthCheckResult.java // public class HealthCheckResult // { // /** // * State of the health check. // */ // public Status status = Status.HEALTHY; // // /** // * Optional description to elaborate on the status enum. // */ // public String description; // // /** // * Convenience constructor to set all required fields. // * @param status Status of the check. // */ // public HealthCheckResult(Status status) // { // this.status = status; // } // // /** // * Convenience constructor to set all fields. // * @param status Status of the check. // * @param description Optional descriptipn to elaborate on the status. // */ // public HealthCheckResult(Status status, String description) // { // this.status = status; // this.description = description; // } // } // // Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/Status.java // public enum Status // { // HEALTHY, // IMPAIRED, // UNHEALTHY, // UNKNOWN // }
import com.codahale.metrics.health.HealthCheck; import com.homeadvisor.robusto.health.HealthCheckAwareClient; import com.homeadvisor.robusto.health.HealthCheckResult; import com.homeadvisor.robusto.health.Status; import java.util.Map;
/* * Copyright 2016 HomeAdvisor, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.homeadvisor.robusto.health.codahale; /** * Implementation of {@link HealthCheckAwareClient} that reports health using * Codahale's {@link HealthCheck}. */ public class CodahaleClientHealthCheck extends HealthCheck implements HealthCheckAwareClient { @Override protected Result check() { // // Get the parent results first // boolean isUnhealthy = false; StringBuilder msg = new StringBuilder(); try { Map<String, HealthCheckResult> results = doAllChecks(); // // Convert results into Codahale objects. Any result that isnt HEALTHY // gets converted into a Codahale UNHEALTHY object. // for(Map.Entry<String, HealthCheckResult> entry : results.entrySet()) { msg.append(entry.getKey()) .append(" [").append(entry.getValue().status).append("]") .append(entry.getValue().description != null ? " - " + entry.getValue().description : "") .append("; ");
// Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/HealthCheckAwareClient.java // public interface HealthCheckAwareClient // { // /** // * List of healthchecks to execute to determine overall health. // */ // List<HealthCheck> checks = new ArrayList<>(); // // // // // Interface methods // // // // /** // * Add a new {@link HealthCheck} to be executed as part of the overall // * client health. HealthChecks will be executed in the order in which they // * are registered. // * @param check // */ // default void registerCheck(HealthCheck check) // { // checks.add(check); // } // // /** // * Main method for determining client health. Default implementation is to // * simply execute all registered handlers and combine them into a single // * list of results. // * @return List of individual results. // */ // default Map<String, HealthCheckResult> doAllChecks() // { // Map<String, HealthCheckResult> results = new TreeMap<>(); // // for(HealthCheck check : checks) // { // results.put(check.getClass().getSimpleName(), check.doCheck()); // } // // return results; // } // } // // Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/HealthCheckResult.java // public class HealthCheckResult // { // /** // * State of the health check. // */ // public Status status = Status.HEALTHY; // // /** // * Optional description to elaborate on the status enum. // */ // public String description; // // /** // * Convenience constructor to set all required fields. // * @param status Status of the check. // */ // public HealthCheckResult(Status status) // { // this.status = status; // } // // /** // * Convenience constructor to set all fields. // * @param status Status of the check. // * @param description Optional descriptipn to elaborate on the status. // */ // public HealthCheckResult(Status status, String description) // { // this.status = status; // this.description = description; // } // } // // Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/Status.java // public enum Status // { // HEALTHY, // IMPAIRED, // UNHEALTHY, // UNKNOWN // } // Path: robusto-codahale/src/main/java/com/homeadvisor/robusto/health/codahale/CodahaleClientHealthCheck.java import com.codahale.metrics.health.HealthCheck; import com.homeadvisor.robusto.health.HealthCheckAwareClient; import com.homeadvisor.robusto.health.HealthCheckResult; import com.homeadvisor.robusto.health.Status; import java.util.Map; /* * Copyright 2016 HomeAdvisor, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.homeadvisor.robusto.health.codahale; /** * Implementation of {@link HealthCheckAwareClient} that reports health using * Codahale's {@link HealthCheck}. */ public class CodahaleClientHealthCheck extends HealthCheck implements HealthCheckAwareClient { @Override protected Result check() { // // Get the parent results first // boolean isUnhealthy = false; StringBuilder msg = new StringBuilder(); try { Map<String, HealthCheckResult> results = doAllChecks(); // // Convert results into Codahale objects. Any result that isnt HEALTHY // gets converted into a Codahale UNHEALTHY object. // for(Map.Entry<String, HealthCheckResult> entry : results.entrySet()) { msg.append(entry.getKey()) .append(" [").append(entry.getValue().status).append("]") .append(entry.getValue().description != null ? " - " + entry.getValue().description : "") .append("; ");
if(entry.getValue().status != Status.HEALTHY)
HomeAdvisor/Robusto
robusto-core/src/main/java/com/homeadvisor/robusto/health/hystrix/HystrixHealthCheck.java
// Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/HealthCheckResult.java // public class HealthCheckResult // { // /** // * State of the health check. // */ // public Status status = Status.HEALTHY; // // /** // * Optional description to elaborate on the status enum. // */ // public String description; // // /** // * Convenience constructor to set all required fields. // * @param status Status of the check. // */ // public HealthCheckResult(Status status) // { // this.status = status; // } // // /** // * Convenience constructor to set all fields. // * @param status Status of the check. // * @param description Optional descriptipn to elaborate on the status. // */ // public HealthCheckResult(Status status, String description) // { // this.status = status; // this.description = description; // } // } // // Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/Status.java // public enum Status // { // HEALTHY, // IMPAIRED, // UNHEALTHY, // UNKNOWN // } // // Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/HealthCheck.java // public interface HealthCheck // { // /** // * Run the health check and return the result. // * @return Result of the health check. // */ // HealthCheckResult doCheck(); // }
import com.homeadvisor.robusto.health.HealthCheckResult; import com.homeadvisor.robusto.health.Status; import com.netflix.hystrix.HystrixCommandKey; import com.netflix.hystrix.HystrixCommandMetrics; import com.netflix.hystrix.util.HystrixRollingNumberEvent; import com.homeadvisor.robusto.health.HealthCheck;
/* * Copyright 2016 HomeAdvisor, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.homeadvisor.robusto.health.hystrix; /** * Implemenation of {@link HealthCheck} that bases health off of * a hystrix command pool. */ public class HystrixHealthCheck implements HealthCheck { /** * The minimum number of failures in a bucket required to report unhealthy. */ private int minNumFailures; /** * Command group key uses to lookup Hystrix metrics. Should likely be the * same as service name. */ private String key; public HystrixHealthCheck(String key, int minNumFailures) { this.key = key; this.minNumFailures = minNumFailures; } @Override
// Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/HealthCheckResult.java // public class HealthCheckResult // { // /** // * State of the health check. // */ // public Status status = Status.HEALTHY; // // /** // * Optional description to elaborate on the status enum. // */ // public String description; // // /** // * Convenience constructor to set all required fields. // * @param status Status of the check. // */ // public HealthCheckResult(Status status) // { // this.status = status; // } // // /** // * Convenience constructor to set all fields. // * @param status Status of the check. // * @param description Optional descriptipn to elaborate on the status. // */ // public HealthCheckResult(Status status, String description) // { // this.status = status; // this.description = description; // } // } // // Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/Status.java // public enum Status // { // HEALTHY, // IMPAIRED, // UNHEALTHY, // UNKNOWN // } // // Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/HealthCheck.java // public interface HealthCheck // { // /** // * Run the health check and return the result. // * @return Result of the health check. // */ // HealthCheckResult doCheck(); // } // Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/hystrix/HystrixHealthCheck.java import com.homeadvisor.robusto.health.HealthCheckResult; import com.homeadvisor.robusto.health.Status; import com.netflix.hystrix.HystrixCommandKey; import com.netflix.hystrix.HystrixCommandMetrics; import com.netflix.hystrix.util.HystrixRollingNumberEvent; import com.homeadvisor.robusto.health.HealthCheck; /* * Copyright 2016 HomeAdvisor, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.homeadvisor.robusto.health.hystrix; /** * Implemenation of {@link HealthCheck} that bases health off of * a hystrix command pool. */ public class HystrixHealthCheck implements HealthCheck { /** * The minimum number of failures in a bucket required to report unhealthy. */ private int minNumFailures; /** * Command group key uses to lookup Hystrix metrics. Should likely be the * same as service name. */ private String key; public HystrixHealthCheck(String key, int minNumFailures) { this.key = key; this.minNumFailures = minNumFailures; } @Override
public HealthCheckResult doCheck()
HomeAdvisor/Robusto
robusto-core/src/main/java/com/homeadvisor/robusto/health/hystrix/HystrixHealthCheck.java
// Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/HealthCheckResult.java // public class HealthCheckResult // { // /** // * State of the health check. // */ // public Status status = Status.HEALTHY; // // /** // * Optional description to elaborate on the status enum. // */ // public String description; // // /** // * Convenience constructor to set all required fields. // * @param status Status of the check. // */ // public HealthCheckResult(Status status) // { // this.status = status; // } // // /** // * Convenience constructor to set all fields. // * @param status Status of the check. // * @param description Optional descriptipn to elaborate on the status. // */ // public HealthCheckResult(Status status, String description) // { // this.status = status; // this.description = description; // } // } // // Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/Status.java // public enum Status // { // HEALTHY, // IMPAIRED, // UNHEALTHY, // UNKNOWN // } // // Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/HealthCheck.java // public interface HealthCheck // { // /** // * Run the health check and return the result. // * @return Result of the health check. // */ // HealthCheckResult doCheck(); // }
import com.homeadvisor.robusto.health.HealthCheckResult; import com.homeadvisor.robusto.health.Status; import com.netflix.hystrix.HystrixCommandKey; import com.netflix.hystrix.HystrixCommandMetrics; import com.netflix.hystrix.util.HystrixRollingNumberEvent; import com.homeadvisor.robusto.health.HealthCheck;
/* * Copyright 2016 HomeAdvisor, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.homeadvisor.robusto.health.hystrix; /** * Implemenation of {@link HealthCheck} that bases health off of * a hystrix command pool. */ public class HystrixHealthCheck implements HealthCheck { /** * The minimum number of failures in a bucket required to report unhealthy. */ private int minNumFailures; /** * Command group key uses to lookup Hystrix metrics. Should likely be the * same as service name. */ private String key; public HystrixHealthCheck(String key, int minNumFailures) { this.key = key; this.minNumFailures = minNumFailures; } @Override public HealthCheckResult doCheck() { // // Lookup the command group using the provided key. These may be null if // no ApiCommands have been created and executed so no need to panic. // try { HystrixCommandKey cmdKey = HystrixCommandKey.Factory.asKey(key); if (cmdKey == null) {
// Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/HealthCheckResult.java // public class HealthCheckResult // { // /** // * State of the health check. // */ // public Status status = Status.HEALTHY; // // /** // * Optional description to elaborate on the status enum. // */ // public String description; // // /** // * Convenience constructor to set all required fields. // * @param status Status of the check. // */ // public HealthCheckResult(Status status) // { // this.status = status; // } // // /** // * Convenience constructor to set all fields. // * @param status Status of the check. // * @param description Optional descriptipn to elaborate on the status. // */ // public HealthCheckResult(Status status, String description) // { // this.status = status; // this.description = description; // } // } // // Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/Status.java // public enum Status // { // HEALTHY, // IMPAIRED, // UNHEALTHY, // UNKNOWN // } // // Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/HealthCheck.java // public interface HealthCheck // { // /** // * Run the health check and return the result. // * @return Result of the health check. // */ // HealthCheckResult doCheck(); // } // Path: robusto-core/src/main/java/com/homeadvisor/robusto/health/hystrix/HystrixHealthCheck.java import com.homeadvisor.robusto.health.HealthCheckResult; import com.homeadvisor.robusto.health.Status; import com.netflix.hystrix.HystrixCommandKey; import com.netflix.hystrix.HystrixCommandMetrics; import com.netflix.hystrix.util.HystrixRollingNumberEvent; import com.homeadvisor.robusto.health.HealthCheck; /* * Copyright 2016 HomeAdvisor, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.homeadvisor.robusto.health.hystrix; /** * Implemenation of {@link HealthCheck} that bases health off of * a hystrix command pool. */ public class HystrixHealthCheck implements HealthCheck { /** * The minimum number of failures in a bucket required to report unhealthy. */ private int minNumFailures; /** * Command group key uses to lookup Hystrix metrics. Should likely be the * same as service name. */ private String key; public HystrixHealthCheck(String key, int minNumFailures) { this.key = key; this.minNumFailures = minNumFailures; } @Override public HealthCheckResult doCheck() { // // Lookup the command group using the provided key. These may be null if // no ApiCommands have been created and executed so no need to panic. // try { HystrixCommandKey cmdKey = HystrixCommandKey.Factory.asKey(key); if (cmdKey == null) {
return new HealthCheckResult(Status.HEALTHY);
jfschaefer/layeredgraphlayout
src/main/java/de/jfschaefer/layeredgraphlayout/lgraph/Layer.java
// Path: src/main/java/de/jfschaefer/layeredgraphlayout/util/Pair.java // public class Pair<A, B> { // public final A first; // public final B second; // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // }
import de.jfschaefer.layeredgraphlayout.util.Pair; import java.util.*;
package de.jfschaefer.layeredgraphlayout.lgraph; /** * Created by jfschaefer on 7/31/15. */ public class Layer { protected int layer; protected ArrayList<LNode> elements; protected LGraphConfig config; public Layer(int layer, LGraphConfig config) { this.layer = layer; elements = new ArrayList<LNode>(); this.config = config; } public void addNode(LNode node) { node.setPos(elements.size()); elements.add(node); } ArrayList<LNode> getElements() { return elements; }
// Path: src/main/java/de/jfschaefer/layeredgraphlayout/util/Pair.java // public class Pair<A, B> { // public final A first; // public final B second; // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // } // Path: src/main/java/de/jfschaefer/layeredgraphlayout/lgraph/Layer.java import de.jfschaefer.layeredgraphlayout.util.Pair; import java.util.*; package de.jfschaefer.layeredgraphlayout.lgraph; /** * Created by jfschaefer on 7/31/15. */ public class Layer { protected int layer; protected ArrayList<LNode> elements; protected LGraphConfig config; public Layer(int layer, LGraphConfig config) { this.layer = layer; elements = new ArrayList<LNode>(); this.config = config; } public void addNode(LNode node) { node.setPos(elements.size()); elements.add(node); } ArrayList<LNode> getElements() { return elements; }
ArrayList<Pair<LNode, LNode>> getChildConnections() {
jfschaefer/layeredgraphlayout
src/test/java/de/jfschaefer/layeredgraphlayout/lgraph/LGraphTest.java
// Path: src/main/java/de/jfschaefer/layeredgraphlayout/Edge.java // public class Edge<V, E> { // protected E originalEdge; // protected Node<V, E> from, to; // protected boolean flipped = false; // protected boolean locked = false; // // public Edge(E original, Node<V, E> from, Node<V, E> to) { // originalEdge = original; // this.from = from; // this.to = to; // from.addOutgoingEdge(this); // to.addIngoingEdge(this); // } // // public E getOriginalEdge() { // return originalEdge; // } // // public Node<V, E> getFrom() { // return flipped ? to : from; // } // // public Node<V, E> getTo() { // return flipped ? from : to; // } // // public Node<V, E> getRealFrom() { // return from; // } // // public Node<V, E> getRealTo() { // return to; // } // // public boolean isFlipped() { // return flipped; // } // // public void flip() { // assert !locked; // getFrom().reverseOutgoingEdge(this); // getTo().reverseIngoingEdge(this); // flipped = !flipped; // } // // public void lock() { // locked = true; // } // // public boolean isLocked() { // return locked; // } // } // // Path: src/main/java/de/jfschaefer/layeredgraphlayout/Node.java // public class Node<V, E> { // protected V originalNode; // protected double width, height; // protected Set<Edge<V, E>> outgoingEdges; // protected Set<Edge<V, E>> ingoingEdges; // // public Node(V original, double width, double height) { // originalNode = original; // this.width = width; // this.height = height; // outgoingEdges = new HashSet<Edge<V, E>>(); // ingoingEdges = new HashSet<Edge<V, E>>(); // } // // void addIngoingEdge(Edge<V, E> edge) { // ingoingEdges.add(edge); // } // // void addOutgoingEdge(Edge<V, E> edge) { // outgoingEdges.add(edge); // } // // public void reverseIngoingEdge(Edge<V, E> edge) { // assert ingoingEdges.contains(edge); // ingoingEdges.remove(edge); // outgoingEdges.add(edge); // } // // public void reverseOutgoingEdge(Edge<V, E> edge) { // assert outgoingEdges.contains(edge); // outgoingEdges.remove(edge); // ingoingEdges.add(edge); // } // // public final Set<Edge<V, E>> getOutgoingEdges() { // return outgoingEdges; // } // // public final Set<Edge<V, E>> getIngoingEdges() { // return ingoingEdges; // } // // public boolean isSink() { // return outgoingEdges.isEmpty(); // } // // public boolean isSource() { // return ingoingEdges.isEmpty(); // } // // public boolean isSinkIn(Collection<Node<V, E>> subset) { // for (Edge<V, E> edge : outgoingEdges) { // if (subset.contains(edge.getTo())) { // return false; // } // } // return true; // } // // public boolean isSourceIn(Collection<Node<V, E>> subset) { // for (Edge<V, E> edge : ingoingEdges) { // if (subset.contains(edge.getFrom())) { // return false; // } // } // return true; // } // // public int inDegree() { // return ingoingEdges.size(); // } // // public int outDegree() { // return outgoingEdges.size(); // } // // public int inDegreeIn(Collection<Node<V, E>> subset) { // int indegree = 0; // for (Edge<V, E> edge : ingoingEdges) { // if (subset.contains(edge.getFrom())) { // indegree ++; // } // } // return indegree; // } // // public int outDegreeIn(Collection<Node<V, E>> subset) { // int outdegree = 0; // for (Edge<V, E> edge : outgoingEdges) { // if (subset.contains(edge.getTo())) { // outdegree ++; // } // } // return outdegree; // } // // public double getWidth() { // return width; // } // // public double getHeight() { // return height; // } // // public V getOriginalNode() { // return originalNode; // } // } // // Path: src/main/java/de/jfschaefer/layeredgraphlayout/util/Pair.java // public class Pair<A, B> { // public final A first; // public final B second; // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // }
import de.jfschaefer.layeredgraphlayout.Edge; import de.jfschaefer.layeredgraphlayout.Node; import de.jfschaefer.layeredgraphlayout.util.Pair; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import java.util.ArrayList;
package de.jfschaefer.layeredgraphlayout.lgraph; /** * Created by jfschaefer on 8/12/15. */ public class LGraphTest extends TestCase { public LGraphTest(String testName) { super(testName); } public static Test suite() { return new TestSuite(LGraphTest.class); } public void testIntersectionCounting() { LGraph<String, String> lgraph = new LGraph<String, String>(new LGraphConfig()); String a1 = "Hello"; String a2 = "World"; String b1 = "Welcome"; String b2 = "Home"; String e1 = "Hello Home"; String e2 = "World Welcome";
// Path: src/main/java/de/jfschaefer/layeredgraphlayout/Edge.java // public class Edge<V, E> { // protected E originalEdge; // protected Node<V, E> from, to; // protected boolean flipped = false; // protected boolean locked = false; // // public Edge(E original, Node<V, E> from, Node<V, E> to) { // originalEdge = original; // this.from = from; // this.to = to; // from.addOutgoingEdge(this); // to.addIngoingEdge(this); // } // // public E getOriginalEdge() { // return originalEdge; // } // // public Node<V, E> getFrom() { // return flipped ? to : from; // } // // public Node<V, E> getTo() { // return flipped ? from : to; // } // // public Node<V, E> getRealFrom() { // return from; // } // // public Node<V, E> getRealTo() { // return to; // } // // public boolean isFlipped() { // return flipped; // } // // public void flip() { // assert !locked; // getFrom().reverseOutgoingEdge(this); // getTo().reverseIngoingEdge(this); // flipped = !flipped; // } // // public void lock() { // locked = true; // } // // public boolean isLocked() { // return locked; // } // } // // Path: src/main/java/de/jfschaefer/layeredgraphlayout/Node.java // public class Node<V, E> { // protected V originalNode; // protected double width, height; // protected Set<Edge<V, E>> outgoingEdges; // protected Set<Edge<V, E>> ingoingEdges; // // public Node(V original, double width, double height) { // originalNode = original; // this.width = width; // this.height = height; // outgoingEdges = new HashSet<Edge<V, E>>(); // ingoingEdges = new HashSet<Edge<V, E>>(); // } // // void addIngoingEdge(Edge<V, E> edge) { // ingoingEdges.add(edge); // } // // void addOutgoingEdge(Edge<V, E> edge) { // outgoingEdges.add(edge); // } // // public void reverseIngoingEdge(Edge<V, E> edge) { // assert ingoingEdges.contains(edge); // ingoingEdges.remove(edge); // outgoingEdges.add(edge); // } // // public void reverseOutgoingEdge(Edge<V, E> edge) { // assert outgoingEdges.contains(edge); // outgoingEdges.remove(edge); // ingoingEdges.add(edge); // } // // public final Set<Edge<V, E>> getOutgoingEdges() { // return outgoingEdges; // } // // public final Set<Edge<V, E>> getIngoingEdges() { // return ingoingEdges; // } // // public boolean isSink() { // return outgoingEdges.isEmpty(); // } // // public boolean isSource() { // return ingoingEdges.isEmpty(); // } // // public boolean isSinkIn(Collection<Node<V, E>> subset) { // for (Edge<V, E> edge : outgoingEdges) { // if (subset.contains(edge.getTo())) { // return false; // } // } // return true; // } // // public boolean isSourceIn(Collection<Node<V, E>> subset) { // for (Edge<V, E> edge : ingoingEdges) { // if (subset.contains(edge.getFrom())) { // return false; // } // } // return true; // } // // public int inDegree() { // return ingoingEdges.size(); // } // // public int outDegree() { // return outgoingEdges.size(); // } // // public int inDegreeIn(Collection<Node<V, E>> subset) { // int indegree = 0; // for (Edge<V, E> edge : ingoingEdges) { // if (subset.contains(edge.getFrom())) { // indegree ++; // } // } // return indegree; // } // // public int outDegreeIn(Collection<Node<V, E>> subset) { // int outdegree = 0; // for (Edge<V, E> edge : outgoingEdges) { // if (subset.contains(edge.getTo())) { // outdegree ++; // } // } // return outdegree; // } // // public double getWidth() { // return width; // } // // public double getHeight() { // return height; // } // // public V getOriginalNode() { // return originalNode; // } // } // // Path: src/main/java/de/jfschaefer/layeredgraphlayout/util/Pair.java // public class Pair<A, B> { // public final A first; // public final B second; // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // } // Path: src/test/java/de/jfschaefer/layeredgraphlayout/lgraph/LGraphTest.java import de.jfschaefer.layeredgraphlayout.Edge; import de.jfschaefer.layeredgraphlayout.Node; import de.jfschaefer.layeredgraphlayout.util.Pair; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import java.util.ArrayList; package de.jfschaefer.layeredgraphlayout.lgraph; /** * Created by jfschaefer on 8/12/15. */ public class LGraphTest extends TestCase { public LGraphTest(String testName) { super(testName); } public static Test suite() { return new TestSuite(LGraphTest.class); } public void testIntersectionCounting() { LGraph<String, String> lgraph = new LGraph<String, String>(new LGraphConfig()); String a1 = "Hello"; String a2 = "World"; String b1 = "Welcome"; String b2 = "Home"; String e1 = "Hello Home"; String e2 = "World Welcome";
Node<String, String> na1 = new Node<String, String>(a1, 100, 20);
jfschaefer/layeredgraphlayout
src/main/java/de/jfschaefer/layeredgraphlayout/layout/Layout.java
// Path: src/main/java/de/jfschaefer/layeredgraphlayout/util/Pair.java // public class Pair<A, B> { // public final A first; // public final B second; // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // } // // Path: src/main/java/de/jfschaefer/layeredgraphlayout/Node.java // public class Node<V, E> { // protected V originalNode; // protected double width, height; // protected Set<Edge<V, E>> outgoingEdges; // protected Set<Edge<V, E>> ingoingEdges; // // public Node(V original, double width, double height) { // originalNode = original; // this.width = width; // this.height = height; // outgoingEdges = new HashSet<Edge<V, E>>(); // ingoingEdges = new HashSet<Edge<V, E>>(); // } // // void addIngoingEdge(Edge<V, E> edge) { // ingoingEdges.add(edge); // } // // void addOutgoingEdge(Edge<V, E> edge) { // outgoingEdges.add(edge); // } // // public void reverseIngoingEdge(Edge<V, E> edge) { // assert ingoingEdges.contains(edge); // ingoingEdges.remove(edge); // outgoingEdges.add(edge); // } // // public void reverseOutgoingEdge(Edge<V, E> edge) { // assert outgoingEdges.contains(edge); // outgoingEdges.remove(edge); // ingoingEdges.add(edge); // } // // public final Set<Edge<V, E>> getOutgoingEdges() { // return outgoingEdges; // } // // public final Set<Edge<V, E>> getIngoingEdges() { // return ingoingEdges; // } // // public boolean isSink() { // return outgoingEdges.isEmpty(); // } // // public boolean isSource() { // return ingoingEdges.isEmpty(); // } // // public boolean isSinkIn(Collection<Node<V, E>> subset) { // for (Edge<V, E> edge : outgoingEdges) { // if (subset.contains(edge.getTo())) { // return false; // } // } // return true; // } // // public boolean isSourceIn(Collection<Node<V, E>> subset) { // for (Edge<V, E> edge : ingoingEdges) { // if (subset.contains(edge.getFrom())) { // return false; // } // } // return true; // } // // public int inDegree() { // return ingoingEdges.size(); // } // // public int outDegree() { // return outgoingEdges.size(); // } // // public int inDegreeIn(Collection<Node<V, E>> subset) { // int indegree = 0; // for (Edge<V, E> edge : ingoingEdges) { // if (subset.contains(edge.getFrom())) { // indegree ++; // } // } // return indegree; // } // // public int outDegreeIn(Collection<Node<V, E>> subset) { // int outdegree = 0; // for (Edge<V, E> edge : outgoingEdges) { // if (subset.contains(edge.getTo())) { // outdegree ++; // } // } // return outdegree; // } // // public double getWidth() { // return width; // } // // public double getHeight() { // return height; // } // // public V getOriginalNode() { // return originalNode; // } // } // // Path: src/main/java/de/jfschaefer/layeredgraphlayout/Edge.java // public class Edge<V, E> { // protected E originalEdge; // protected Node<V, E> from, to; // protected boolean flipped = false; // protected boolean locked = false; // // public Edge(E original, Node<V, E> from, Node<V, E> to) { // originalEdge = original; // this.from = from; // this.to = to; // from.addOutgoingEdge(this); // to.addIngoingEdge(this); // } // // public E getOriginalEdge() { // return originalEdge; // } // // public Node<V, E> getFrom() { // return flipped ? to : from; // } // // public Node<V, E> getTo() { // return flipped ? from : to; // } // // public Node<V, E> getRealFrom() { // return from; // } // // public Node<V, E> getRealTo() { // return to; // } // // public boolean isFlipped() { // return flipped; // } // // public void flip() { // assert !locked; // getFrom().reverseOutgoingEdge(this); // getTo().reverseIngoingEdge(this); // flipped = !flipped; // } // // public void lock() { // locked = true; // } // // public boolean isLocked() { // return locked; // } // }
import de.jfschaefer.layeredgraphlayout.util.Pair; import de.jfschaefer.layeredgraphlayout.Node; import de.jfschaefer.layeredgraphlayout.Edge; import java.util.*;
package de.jfschaefer.layeredgraphlayout.layout; /** * Created by jfschaefer on 7/31/15. */ public class Layout<V, E> { protected Map<V, Pair<Node<V, E>, Point>> nodeMap;
// Path: src/main/java/de/jfschaefer/layeredgraphlayout/util/Pair.java // public class Pair<A, B> { // public final A first; // public final B second; // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // } // // Path: src/main/java/de/jfschaefer/layeredgraphlayout/Node.java // public class Node<V, E> { // protected V originalNode; // protected double width, height; // protected Set<Edge<V, E>> outgoingEdges; // protected Set<Edge<V, E>> ingoingEdges; // // public Node(V original, double width, double height) { // originalNode = original; // this.width = width; // this.height = height; // outgoingEdges = new HashSet<Edge<V, E>>(); // ingoingEdges = new HashSet<Edge<V, E>>(); // } // // void addIngoingEdge(Edge<V, E> edge) { // ingoingEdges.add(edge); // } // // void addOutgoingEdge(Edge<V, E> edge) { // outgoingEdges.add(edge); // } // // public void reverseIngoingEdge(Edge<V, E> edge) { // assert ingoingEdges.contains(edge); // ingoingEdges.remove(edge); // outgoingEdges.add(edge); // } // // public void reverseOutgoingEdge(Edge<V, E> edge) { // assert outgoingEdges.contains(edge); // outgoingEdges.remove(edge); // ingoingEdges.add(edge); // } // // public final Set<Edge<V, E>> getOutgoingEdges() { // return outgoingEdges; // } // // public final Set<Edge<V, E>> getIngoingEdges() { // return ingoingEdges; // } // // public boolean isSink() { // return outgoingEdges.isEmpty(); // } // // public boolean isSource() { // return ingoingEdges.isEmpty(); // } // // public boolean isSinkIn(Collection<Node<V, E>> subset) { // for (Edge<V, E> edge : outgoingEdges) { // if (subset.contains(edge.getTo())) { // return false; // } // } // return true; // } // // public boolean isSourceIn(Collection<Node<V, E>> subset) { // for (Edge<V, E> edge : ingoingEdges) { // if (subset.contains(edge.getFrom())) { // return false; // } // } // return true; // } // // public int inDegree() { // return ingoingEdges.size(); // } // // public int outDegree() { // return outgoingEdges.size(); // } // // public int inDegreeIn(Collection<Node<V, E>> subset) { // int indegree = 0; // for (Edge<V, E> edge : ingoingEdges) { // if (subset.contains(edge.getFrom())) { // indegree ++; // } // } // return indegree; // } // // public int outDegreeIn(Collection<Node<V, E>> subset) { // int outdegree = 0; // for (Edge<V, E> edge : outgoingEdges) { // if (subset.contains(edge.getTo())) { // outdegree ++; // } // } // return outdegree; // } // // public double getWidth() { // return width; // } // // public double getHeight() { // return height; // } // // public V getOriginalNode() { // return originalNode; // } // } // // Path: src/main/java/de/jfschaefer/layeredgraphlayout/Edge.java // public class Edge<V, E> { // protected E originalEdge; // protected Node<V, E> from, to; // protected boolean flipped = false; // protected boolean locked = false; // // public Edge(E original, Node<V, E> from, Node<V, E> to) { // originalEdge = original; // this.from = from; // this.to = to; // from.addOutgoingEdge(this); // to.addIngoingEdge(this); // } // // public E getOriginalEdge() { // return originalEdge; // } // // public Node<V, E> getFrom() { // return flipped ? to : from; // } // // public Node<V, E> getTo() { // return flipped ? from : to; // } // // public Node<V, E> getRealFrom() { // return from; // } // // public Node<V, E> getRealTo() { // return to; // } // // public boolean isFlipped() { // return flipped; // } // // public void flip() { // assert !locked; // getFrom().reverseOutgoingEdge(this); // getTo().reverseIngoingEdge(this); // flipped = !flipped; // } // // public void lock() { // locked = true; // } // // public boolean isLocked() { // return locked; // } // } // Path: src/main/java/de/jfschaefer/layeredgraphlayout/layout/Layout.java import de.jfschaefer.layeredgraphlayout.util.Pair; import de.jfschaefer.layeredgraphlayout.Node; import de.jfschaefer.layeredgraphlayout.Edge; import java.util.*; package de.jfschaefer.layeredgraphlayout.layout; /** * Created by jfschaefer on 7/31/15. */ public class Layout<V, E> { protected Map<V, Pair<Node<V, E>, Point>> nodeMap;
protected Map<E, Pair<Edge<V, E>, ArrayList<EdgeSegment>>> edgeMap;
jfschaefer/layeredgraphlayout
src/test/java/de/jfschaefer/layeredgraphlayout/gengraph/GenGraphTest.java
// Path: src/main/java/de/jfschaefer/layeredgraphlayout/Edge.java // public class Edge<V, E> { // protected E originalEdge; // protected Node<V, E> from, to; // protected boolean flipped = false; // protected boolean locked = false; // // public Edge(E original, Node<V, E> from, Node<V, E> to) { // originalEdge = original; // this.from = from; // this.to = to; // from.addOutgoingEdge(this); // to.addIngoingEdge(this); // } // // public E getOriginalEdge() { // return originalEdge; // } // // public Node<V, E> getFrom() { // return flipped ? to : from; // } // // public Node<V, E> getTo() { // return flipped ? from : to; // } // // public Node<V, E> getRealFrom() { // return from; // } // // public Node<V, E> getRealTo() { // return to; // } // // public boolean isFlipped() { // return flipped; // } // // public void flip() { // assert !locked; // getFrom().reverseOutgoingEdge(this); // getTo().reverseIngoingEdge(this); // flipped = !flipped; // } // // public void lock() { // locked = true; // } // // public boolean isLocked() { // return locked; // } // }
import de.jfschaefer.layeredgraphlayout.Edge; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite;
package de.jfschaefer.layeredgraphlayout.gengraph; /** * Created by jfschaefer on 8/14/15. */ public class GenGraphTest extends TestCase { public GenGraphTest(String testName) { super(testName); } public static Test suite() { return new TestSuite(GenGraphTest.class); } public void testRemoveCyclesGreedy() { GenGraph<String, String> graph = new GenGraph<String, String>(); String[] nodes = {"n1", "n2", "n3"}; String[] edges = {"e1", "e2", "e3"}; graph.addNode(nodes[0], 10d, 10d); graph.addNode(nodes[1], 10d, 10d); graph.addNode(nodes[2], 10d, 10d); graph.addEdge(edges[0], nodes[0], nodes[1]); graph.addEdge(edges[1], nodes[1], nodes[2]); graph.addEdge(edges[2], nodes[2], nodes[0]); graph.removeCyclesGreedy(); int counter = 0; assertEquals(graph.getEdges().size(), 3);
// Path: src/main/java/de/jfschaefer/layeredgraphlayout/Edge.java // public class Edge<V, E> { // protected E originalEdge; // protected Node<V, E> from, to; // protected boolean flipped = false; // protected boolean locked = false; // // public Edge(E original, Node<V, E> from, Node<V, E> to) { // originalEdge = original; // this.from = from; // this.to = to; // from.addOutgoingEdge(this); // to.addIngoingEdge(this); // } // // public E getOriginalEdge() { // return originalEdge; // } // // public Node<V, E> getFrom() { // return flipped ? to : from; // } // // public Node<V, E> getTo() { // return flipped ? from : to; // } // // public Node<V, E> getRealFrom() { // return from; // } // // public Node<V, E> getRealTo() { // return to; // } // // public boolean isFlipped() { // return flipped; // } // // public void flip() { // assert !locked; // getFrom().reverseOutgoingEdge(this); // getTo().reverseIngoingEdge(this); // flipped = !flipped; // } // // public void lock() { // locked = true; // } // // public boolean isLocked() { // return locked; // } // } // Path: src/test/java/de/jfschaefer/layeredgraphlayout/gengraph/GenGraphTest.java import de.jfschaefer.layeredgraphlayout.Edge; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; package de.jfschaefer.layeredgraphlayout.gengraph; /** * Created by jfschaefer on 8/14/15. */ public class GenGraphTest extends TestCase { public GenGraphTest(String testName) { super(testName); } public static Test suite() { return new TestSuite(GenGraphTest.class); } public void testRemoveCyclesGreedy() { GenGraph<String, String> graph = new GenGraph<String, String>(); String[] nodes = {"n1", "n2", "n3"}; String[] edges = {"e1", "e2", "e3"}; graph.addNode(nodes[0], 10d, 10d); graph.addNode(nodes[1], 10d, 10d); graph.addNode(nodes[2], 10d, 10d); graph.addEdge(edges[0], nodes[0], nodes[1]); graph.addEdge(edges[1], nodes[1], nodes[2]); graph.addEdge(edges[2], nodes[2], nodes[0]); graph.removeCyclesGreedy(); int counter = 0; assertEquals(graph.getEdges().size(), 3);
for (Edge edge : graph.getEdges()) {
jfschaefer/layeredgraphlayout
src/main/java/de/jfschaefer/layeredgraphlayout/latex/LatexGenerator.java
// Path: src/main/java/de/jfschaefer/layeredgraphlayout/util/Pair.java // public class Pair<A, B> { // public final A first; // public final B second; // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // }
import de.jfschaefer.layeredgraphlayout.layout.*; import de.jfschaefer.layeredgraphlayout.util.Pair; import java.util.*;
package de.jfschaefer.layeredgraphlayout.latex; /** * Created by jfschaefer on 8/10/15. */ public class LatexGenerator<V, E> { public static <V, E> String generateLatex(Layout<V, E> layout, Map<V, String> nodeMap, Map<E, String> edgeMap, boolean drawBox) { StringBuilder sb = new StringBuilder(); sb.append("\\begin{tikzpicture}\n"); de.jfschaefer.layeredgraphlayout.layout.Vector shift = layout.getShift(); // Step 1: Draw nodes for (V node : layout.getNodeSet()) { sb.append("\\node (rect) at (");
// Path: src/main/java/de/jfschaefer/layeredgraphlayout/util/Pair.java // public class Pair<A, B> { // public final A first; // public final B second; // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // } // Path: src/main/java/de/jfschaefer/layeredgraphlayout/latex/LatexGenerator.java import de.jfschaefer.layeredgraphlayout.layout.*; import de.jfschaefer.layeredgraphlayout.util.Pair; import java.util.*; package de.jfschaefer.layeredgraphlayout.latex; /** * Created by jfschaefer on 8/10/15. */ public class LatexGenerator<V, E> { public static <V, E> String generateLatex(Layout<V, E> layout, Map<V, String> nodeMap, Map<E, String> edgeMap, boolean drawBox) { StringBuilder sb = new StringBuilder(); sb.append("\\begin{tikzpicture}\n"); de.jfschaefer.layeredgraphlayout.layout.Vector shift = layout.getShift(); // Step 1: Draw nodes for (V node : layout.getNodeSet()) { sb.append("\\node (rect) at (");
Pair<Double, Double> size = layout.getNodeSize(node);
jfschaefer/layeredgraphlayout
src/main/java/de/jfschaefer/layeredgraphlayout/visualizationfx/SimpleGraphFXEdgeFactory.java
// Path: src/main/java/de/jfschaefer/layeredgraphlayout/layout/Vector.java // public class Vector { // public final double x; // public final double y; // // public Vector(double x, double y) { // this.x = x; // this.y = y; // } // // public Vector scaled(double l) { // return new Vector(l * x, l * y); // } // // public Vector add(Vector other) { // return new Vector(this.x + other.x, this.y + other.y); // } // } // // Path: src/main/java/de/jfschaefer/layeredgraphlayout/util/Pair.java // public class Pair<A, B> { // public final A first; // public final B second; // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // }
import de.jfschaefer.layeredgraphlayout.layout.*; import de.jfschaefer.layeredgraphlayout.layout.Vector; import de.jfschaefer.layeredgraphlayout.util.Pair; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.geometry.Bounds; import javafx.scene.Group; import javafx.scene.Node; import javafx.scene.control.Label; import javafx.scene.paint.Color; import javafx.scene.paint.Paint; import javafx.scene.shape.CubicCurve; import javafx.scene.shape.Line; import javafx.scene.shape.Polygon; import javafx.scene.transform.Rotate; import java.util.*;
this.labelMap = labelMap; this.color = color; } public Node getEdgeVisualization(E edge, ArrayList<EdgeSegment> segments) { Group g = new Group(); // Step 1: Line for (EdgeSegment segment : segments) { if (segment.isBezier()) { CubicCurve curve = new CubicCurve(segment.getStart().x, segment.getStart().y, segment.getControl1().x, segment.getControl1().y, segment.getControl2().x, segment.getControl2().y, segment.getEnd().x, segment.getEnd().y); curve.setFill(Color.TRANSPARENT); curve.setStroke(color); g.getChildren().add(curve); } else { Line line = new Line(segment.getStart().x, segment.getStart().y, segment.getEnd().x, segment.getEnd().y); line.setStroke(color); g.getChildren().add(line); } } // Step 2: Arrow head if (layoutConfig.getArrowheads()) { Polygon arrowhead = new Polygon(0d, 0d, 4d, 8d, 0d, 4d, -4d, 8d); EdgeSegment segment = segments.get(segments.size() - 1); double fraction = 1d;
// Path: src/main/java/de/jfschaefer/layeredgraphlayout/layout/Vector.java // public class Vector { // public final double x; // public final double y; // // public Vector(double x, double y) { // this.x = x; // this.y = y; // } // // public Vector scaled(double l) { // return new Vector(l * x, l * y); // } // // public Vector add(Vector other) { // return new Vector(this.x + other.x, this.y + other.y); // } // } // // Path: src/main/java/de/jfschaefer/layeredgraphlayout/util/Pair.java // public class Pair<A, B> { // public final A first; // public final B second; // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // } // Path: src/main/java/de/jfschaefer/layeredgraphlayout/visualizationfx/SimpleGraphFXEdgeFactory.java import de.jfschaefer.layeredgraphlayout.layout.*; import de.jfschaefer.layeredgraphlayout.layout.Vector; import de.jfschaefer.layeredgraphlayout.util.Pair; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.geometry.Bounds; import javafx.scene.Group; import javafx.scene.Node; import javafx.scene.control.Label; import javafx.scene.paint.Color; import javafx.scene.paint.Paint; import javafx.scene.shape.CubicCurve; import javafx.scene.shape.Line; import javafx.scene.shape.Polygon; import javafx.scene.transform.Rotate; import java.util.*; this.labelMap = labelMap; this.color = color; } public Node getEdgeVisualization(E edge, ArrayList<EdgeSegment> segments) { Group g = new Group(); // Step 1: Line for (EdgeSegment segment : segments) { if (segment.isBezier()) { CubicCurve curve = new CubicCurve(segment.getStart().x, segment.getStart().y, segment.getControl1().x, segment.getControl1().y, segment.getControl2().x, segment.getControl2().y, segment.getEnd().x, segment.getEnd().y); curve.setFill(Color.TRANSPARENT); curve.setStroke(color); g.getChildren().add(curve); } else { Line line = new Line(segment.getStart().x, segment.getStart().y, segment.getEnd().x, segment.getEnd().y); line.setStroke(color); g.getChildren().add(line); } } // Step 2: Arrow head if (layoutConfig.getArrowheads()) { Polygon arrowhead = new Polygon(0d, 0d, 4d, 8d, 0d, 4d, -4d, 8d); EdgeSegment segment = segments.get(segments.size() - 1); double fraction = 1d;
Vector derivative = segment.getDerivativeAt(fraction);
jfschaefer/layeredgraphlayout
src/main/java/de/jfschaefer/layeredgraphlayout/visualizationfx/SimpleGraphFXEdgeFactory.java
// Path: src/main/java/de/jfschaefer/layeredgraphlayout/layout/Vector.java // public class Vector { // public final double x; // public final double y; // // public Vector(double x, double y) { // this.x = x; // this.y = y; // } // // public Vector scaled(double l) { // return new Vector(l * x, l * y); // } // // public Vector add(Vector other) { // return new Vector(this.x + other.x, this.y + other.y); // } // } // // Path: src/main/java/de/jfschaefer/layeredgraphlayout/util/Pair.java // public class Pair<A, B> { // public final A first; // public final B second; // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // }
import de.jfschaefer.layeredgraphlayout.layout.*; import de.jfschaefer.layeredgraphlayout.layout.Vector; import de.jfschaefer.layeredgraphlayout.util.Pair; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.geometry.Bounds; import javafx.scene.Group; import javafx.scene.Node; import javafx.scene.control.Label; import javafx.scene.paint.Color; import javafx.scene.paint.Paint; import javafx.scene.shape.CubicCurve; import javafx.scene.shape.Line; import javafx.scene.shape.Polygon; import javafx.scene.transform.Rotate; import java.util.*;
segment.getEnd().x, segment.getEnd().y); curve.setFill(Color.TRANSPARENT); curve.setStroke(color); g.getChildren().add(curve); } else { Line line = new Line(segment.getStart().x, segment.getStart().y, segment.getEnd().x, segment.getEnd().y); line.setStroke(color); g.getChildren().add(line); } } // Step 2: Arrow head if (layoutConfig.getArrowheads()) { Polygon arrowhead = new Polygon(0d, 0d, 4d, 8d, 0d, 4d, -4d, 8d); EdgeSegment segment = segments.get(segments.size() - 1); double fraction = 1d; Vector derivative = segment.getDerivativeAt(fraction); double angle = Math.atan2(derivative.y, derivative.x); Point position = segment.getAt(fraction); arrowhead.setLayoutX(position.x); arrowhead.setLayoutY(position.y); arrowhead.getTransforms().add(new Rotate(365d / (2 * Math.PI) * angle + 90, 0, 0)); arrowhead.setFill(color); g.getChildren().add(arrowhead); } // Step 3: Label String labelString = labelMap.get(edge); if (labelString != null && !labelString.isEmpty()) {
// Path: src/main/java/de/jfschaefer/layeredgraphlayout/layout/Vector.java // public class Vector { // public final double x; // public final double y; // // public Vector(double x, double y) { // this.x = x; // this.y = y; // } // // public Vector scaled(double l) { // return new Vector(l * x, l * y); // } // // public Vector add(Vector other) { // return new Vector(this.x + other.x, this.y + other.y); // } // } // // Path: src/main/java/de/jfschaefer/layeredgraphlayout/util/Pair.java // public class Pair<A, B> { // public final A first; // public final B second; // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // } // Path: src/main/java/de/jfschaefer/layeredgraphlayout/visualizationfx/SimpleGraphFXEdgeFactory.java import de.jfschaefer.layeredgraphlayout.layout.*; import de.jfschaefer.layeredgraphlayout.layout.Vector; import de.jfschaefer.layeredgraphlayout.util.Pair; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.geometry.Bounds; import javafx.scene.Group; import javafx.scene.Node; import javafx.scene.control.Label; import javafx.scene.paint.Color; import javafx.scene.paint.Paint; import javafx.scene.shape.CubicCurve; import javafx.scene.shape.Line; import javafx.scene.shape.Polygon; import javafx.scene.transform.Rotate; import java.util.*; segment.getEnd().x, segment.getEnd().y); curve.setFill(Color.TRANSPARENT); curve.setStroke(color); g.getChildren().add(curve); } else { Line line = new Line(segment.getStart().x, segment.getStart().y, segment.getEnd().x, segment.getEnd().y); line.setStroke(color); g.getChildren().add(line); } } // Step 2: Arrow head if (layoutConfig.getArrowheads()) { Polygon arrowhead = new Polygon(0d, 0d, 4d, 8d, 0d, 4d, -4d, 8d); EdgeSegment segment = segments.get(segments.size() - 1); double fraction = 1d; Vector derivative = segment.getDerivativeAt(fraction); double angle = Math.atan2(derivative.y, derivative.x); Point position = segment.getAt(fraction); arrowhead.setLayoutX(position.x); arrowhead.setLayoutY(position.y); arrowhead.getTransforms().add(new Rotate(365d / (2 * Math.PI) * angle + 90, 0, 0)); arrowhead.setFill(color); g.getChildren().add(arrowhead); } // Step 3: Label String labelString = labelMap.get(edge); if (labelString != null && !labelString.isEmpty()) {
final Pair<Point, Double> edgePosition = Util.naiveGetLabelPosition(segments);
jfschaefer/layeredgraphlayout
src/main/java/de/jfschaefer/layeredgraphlayout/visualizationfx/GraphFXEdgeFactory.java
// Path: src/main/java/de/jfschaefer/layeredgraphlayout/layout/EdgeSegment.java // public class EdgeSegment { // public final Point start; // public final Point control1; // public final Point control2; // public final Point end; // public final boolean bezier; //true if cubic bezier curve, false if linear // // public EdgeSegment(Point start, Point end) { // this.start = start; // this.control1 = null; // this.control2 = null; // this.end = end; // bezier = false; // } // // public EdgeSegment(Point start, Point control1, Point control2, Point end) { // this.start = start; // this.control1 = control1; // this.control2 = control2; // this.end = end; // bezier = true; // } // // public EdgeSegment addVector(Vector v) { // if (bezier) { // return new EdgeSegment(start.addVector(v), control1.addVector(v), control2.addVector(v), end.addVector(v)); // } else { // return new EdgeSegment(start.addVector(v), end.addVector(v)); // } // } // // public boolean isBezier() { // return bezier; // } // // public Point getStart() { // return start; // } // // public Point getControl1() { // return control1; // } // // public Point getControl2() { // return control2; // } // // public Point getEnd() { // return end; // } // // public EdgeSegment reversed() { // if (bezier) { // return new EdgeSegment(end, control2, control1, start); // } else { // return new EdgeSegment(end, start); // } // } // // public Point getAt(double fraction) { // if (bezier) { // Vector p0 = Point.ORIGIN.vectorTo(start); // Vector p1 = Point.ORIGIN.vectorTo(control1); // Vector p2 = Point.ORIGIN.vectorTo(control2); // Vector p3 = Point.ORIGIN.vectorTo(end); // return Point.ORIGIN.addVector(p0.scaled((1-fraction)*(1-fraction)*(1-fraction))) // .addVector(p1.scaled(3*(1-fraction)*(1-fraction)*fraction)) // .addVector(p2.scaled(3*(1-fraction)*fraction*fraction)) // .addVector(p3.scaled(fraction*fraction*fraction)); // } else { // return start.addVector(start.vectorTo(end).scaled(fraction)); // } // } // // public Vector getDerivativeAt(double fraction) { // if (bezier) { // Vector a = start.vectorTo(control1); // Vector b = control1.vectorTo(control2); // Vector c = control2.vectorTo(end); // // return a.scaled(3*(1-fraction)*(1-fraction)) // .add(b.scaled(6*(1-fraction)*fraction)) // .add(c.scaled(3*fraction*fraction)); // } else { // return start.vectorTo(end); // } // } // } // // Path: src/main/java/de/jfschaefer/layeredgraphlayout/layout/LayoutConfig.java // public class LayoutConfig { // protected boolean bezier = true; // protected boolean arrowheads = true; // protected double controlPointDistance = 0.25d; // protected double graphPadding = 16d; // // public void setBezier(boolean bezier) { // this.bezier = bezier; // } // // public boolean getBezier() { // return bezier; // } // // public void setArrowheads(boolean arrowheads) { // this.arrowheads = arrowheads; // } // // public boolean getArrowheads() { // return arrowheads; // } // // public void setControlPointDistance(double value) { // controlPointDistance = value; // } // // public double getControlPointDistance() { // return controlPointDistance; // } // // public double getGraphPadding() { // return graphPadding; // } // // public void setGraphPadding(double padding) { // graphPadding = padding; // } // }
import de.jfschaefer.layeredgraphlayout.layout.EdgeSegment; import de.jfschaefer.layeredgraphlayout.layout.LayoutConfig; import javafx.scene.Node; import java.util.*;
package de.jfschaefer.layeredgraphlayout.visualizationfx; /** * Created by jfschaefer on 7/31/15. */ public abstract class GraphFXEdgeFactory<E> { protected final LayoutConfig layoutConfig; public GraphFXEdgeFactory(LayoutConfig config) { layoutConfig = config; }
// Path: src/main/java/de/jfschaefer/layeredgraphlayout/layout/EdgeSegment.java // public class EdgeSegment { // public final Point start; // public final Point control1; // public final Point control2; // public final Point end; // public final boolean bezier; //true if cubic bezier curve, false if linear // // public EdgeSegment(Point start, Point end) { // this.start = start; // this.control1 = null; // this.control2 = null; // this.end = end; // bezier = false; // } // // public EdgeSegment(Point start, Point control1, Point control2, Point end) { // this.start = start; // this.control1 = control1; // this.control2 = control2; // this.end = end; // bezier = true; // } // // public EdgeSegment addVector(Vector v) { // if (bezier) { // return new EdgeSegment(start.addVector(v), control1.addVector(v), control2.addVector(v), end.addVector(v)); // } else { // return new EdgeSegment(start.addVector(v), end.addVector(v)); // } // } // // public boolean isBezier() { // return bezier; // } // // public Point getStart() { // return start; // } // // public Point getControl1() { // return control1; // } // // public Point getControl2() { // return control2; // } // // public Point getEnd() { // return end; // } // // public EdgeSegment reversed() { // if (bezier) { // return new EdgeSegment(end, control2, control1, start); // } else { // return new EdgeSegment(end, start); // } // } // // public Point getAt(double fraction) { // if (bezier) { // Vector p0 = Point.ORIGIN.vectorTo(start); // Vector p1 = Point.ORIGIN.vectorTo(control1); // Vector p2 = Point.ORIGIN.vectorTo(control2); // Vector p3 = Point.ORIGIN.vectorTo(end); // return Point.ORIGIN.addVector(p0.scaled((1-fraction)*(1-fraction)*(1-fraction))) // .addVector(p1.scaled(3*(1-fraction)*(1-fraction)*fraction)) // .addVector(p2.scaled(3*(1-fraction)*fraction*fraction)) // .addVector(p3.scaled(fraction*fraction*fraction)); // } else { // return start.addVector(start.vectorTo(end).scaled(fraction)); // } // } // // public Vector getDerivativeAt(double fraction) { // if (bezier) { // Vector a = start.vectorTo(control1); // Vector b = control1.vectorTo(control2); // Vector c = control2.vectorTo(end); // // return a.scaled(3*(1-fraction)*(1-fraction)) // .add(b.scaled(6*(1-fraction)*fraction)) // .add(c.scaled(3*fraction*fraction)); // } else { // return start.vectorTo(end); // } // } // } // // Path: src/main/java/de/jfschaefer/layeredgraphlayout/layout/LayoutConfig.java // public class LayoutConfig { // protected boolean bezier = true; // protected boolean arrowheads = true; // protected double controlPointDistance = 0.25d; // protected double graphPadding = 16d; // // public void setBezier(boolean bezier) { // this.bezier = bezier; // } // // public boolean getBezier() { // return bezier; // } // // public void setArrowheads(boolean arrowheads) { // this.arrowheads = arrowheads; // } // // public boolean getArrowheads() { // return arrowheads; // } // // public void setControlPointDistance(double value) { // controlPointDistance = value; // } // // public double getControlPointDistance() { // return controlPointDistance; // } // // public double getGraphPadding() { // return graphPadding; // } // // public void setGraphPadding(double padding) { // graphPadding = padding; // } // } // Path: src/main/java/de/jfschaefer/layeredgraphlayout/visualizationfx/GraphFXEdgeFactory.java import de.jfschaefer.layeredgraphlayout.layout.EdgeSegment; import de.jfschaefer.layeredgraphlayout.layout.LayoutConfig; import javafx.scene.Node; import java.util.*; package de.jfschaefer.layeredgraphlayout.visualizationfx; /** * Created by jfschaefer on 7/31/15. */ public abstract class GraphFXEdgeFactory<E> { protected final LayoutConfig layoutConfig; public GraphFXEdgeFactory(LayoutConfig config) { layoutConfig = config; }
public abstract Node getEdgeVisualization(E edge, ArrayList<EdgeSegment> segments);
jfschaefer/layeredgraphlayout
src/main/java/de/jfschaefer/layeredgraphlayout/visualizationfx/GraphFX.java
// Path: src/main/java/de/jfschaefer/layeredgraphlayout/util/Pair.java // public class Pair<A, B> { // public final A first; // public final B second; // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // }
import de.jfschaefer.layeredgraphlayout.layout.*; import de.jfschaefer.layeredgraphlayout.util.Pair; import javafx.scene.Group; import javafx.scene.Node; import javafx.scene.control.Control; import javafx.scene.layout.Pane; import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; import java.util.ArrayList;
package de.jfschaefer.layeredgraphlayout.visualizationfx; /** * Created by jfschaefer on 7/31/15. */ public class GraphFX<V, E> extends Group { public GraphFX(Layout<V, E> layout, GraphFXNodeFactory<V> nodeFactory, GraphFXEdgeFactory<E> edgeFactory) { Vector shift = layout.getShift(); /* Rectangle r = new Rectangle(layout.getWidth(), layout.getHeight(), new Color(1d, 1d, 0d, 0.5)); getChildren().add(r); */ for (E edge : layout.getEdgeSet()) { ArrayList<EdgeSegment> segments = layout.getEdgePosition(edge); Node n = edgeFactory.getEdgeVisualization(edge, segments); getChildren().add(n); n.translateXProperty().set(n.translateXProperty().doubleValue() + shift.x); n.translateYProperty().set(n.translateYProperty().doubleValue() + shift.y); } for (V node : layout.getNodeSet()) {
// Path: src/main/java/de/jfschaefer/layeredgraphlayout/util/Pair.java // public class Pair<A, B> { // public final A first; // public final B second; // public Pair(A first, B second) { // this.first = first; // this.second = second; // } // } // Path: src/main/java/de/jfschaefer/layeredgraphlayout/visualizationfx/GraphFX.java import de.jfschaefer.layeredgraphlayout.layout.*; import de.jfschaefer.layeredgraphlayout.util.Pair; import javafx.scene.Group; import javafx.scene.Node; import javafx.scene.control.Control; import javafx.scene.layout.Pane; import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; import java.util.ArrayList; package de.jfschaefer.layeredgraphlayout.visualizationfx; /** * Created by jfschaefer on 7/31/15. */ public class GraphFX<V, E> extends Group { public GraphFX(Layout<V, E> layout, GraphFXNodeFactory<V> nodeFactory, GraphFXEdgeFactory<E> edgeFactory) { Vector shift = layout.getShift(); /* Rectangle r = new Rectangle(layout.getWidth(), layout.getHeight(), new Color(1d, 1d, 0d, 0.5)); getChildren().add(r); */ for (E edge : layout.getEdgeSet()) { ArrayList<EdgeSegment> segments = layout.getEdgePosition(edge); Node n = edgeFactory.getEdgeVisualization(edge, segments); getChildren().add(n); n.translateXProperty().set(n.translateXProperty().doubleValue() + shift.x); n.translateYProperty().set(n.translateYProperty().doubleValue() + shift.y); } for (V node : layout.getNodeSet()) {
Pair<Double, Double> size = layout.getNodeSize(node);
alb-i986/selenium-tinafw
src/test/java/me/alb_i986/selenium/tinafw/ui/WebDriverFactoryLocalTest.java
// Path: src/main/java/me/alb_i986/selenium/tinafw/domain/SupportedBrowser.java // public enum SupportedBrowser { // // CHROME(ChromeDriver.class, DesiredCapabilities.chrome()), // FIREFOX(FirefoxDriver.class, DesiredCapabilities.firefox()), // SAFARI(SafariDriver.class, DesiredCapabilities.safari()), // IE(InternetExplorerDriver.class, DesiredCapabilities.internetExplorer()), // HTML_UNIT(HtmlUnitDriver.class, DesiredCapabilities.htmlUnit()), // ; // // private DesiredCapabilities capabilities; // private Class<? extends WebDriver> concreteWebDriverClass; // // private SupportedBrowser(Class<? extends WebDriver> clazz, DesiredCapabilities capabilities) { // this.concreteWebDriverClass = clazz; // this.capabilities = capabilities; // } // // /** // * @return the concrete WebDriver class corresponding to this SupportedBrowser // */ // public Class<? extends WebDriver> toClass() { // return this.concreteWebDriverClass; // } // // public DesiredCapabilities toCapabilities() { // return this.capabilities; // } // // /** // * @return the lower cased name of this enum constant // */ // @Override // public String toString() { // return super.toString().toLowerCase(); // } // }
import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; import static org.junit.Assume.*; import static org.junit.runners.Parameterized.*; import me.alb_i986.selenium.tinafw.domain.SupportedBrowser; import org.hamcrest.Description; import org.hamcrest.Matcher; import org.hamcrest.TypeSafeMatcher; import org.junit.After; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.openqa.selenium.WebDriver; import java.util.Arrays;
package me.alb_i986.selenium.tinafw.ui; @RunWith(Parameterized.class) public class WebDriverFactoryLocalTest { @Parameters(name = "{0}")
// Path: src/main/java/me/alb_i986/selenium/tinafw/domain/SupportedBrowser.java // public enum SupportedBrowser { // // CHROME(ChromeDriver.class, DesiredCapabilities.chrome()), // FIREFOX(FirefoxDriver.class, DesiredCapabilities.firefox()), // SAFARI(SafariDriver.class, DesiredCapabilities.safari()), // IE(InternetExplorerDriver.class, DesiredCapabilities.internetExplorer()), // HTML_UNIT(HtmlUnitDriver.class, DesiredCapabilities.htmlUnit()), // ; // // private DesiredCapabilities capabilities; // private Class<? extends WebDriver> concreteWebDriverClass; // // private SupportedBrowser(Class<? extends WebDriver> clazz, DesiredCapabilities capabilities) { // this.concreteWebDriverClass = clazz; // this.capabilities = capabilities; // } // // /** // * @return the concrete WebDriver class corresponding to this SupportedBrowser // */ // public Class<? extends WebDriver> toClass() { // return this.concreteWebDriverClass; // } // // public DesiredCapabilities toCapabilities() { // return this.capabilities; // } // // /** // * @return the lower cased name of this enum constant // */ // @Override // public String toString() { // return super.toString().toLowerCase(); // } // } // Path: src/test/java/me/alb_i986/selenium/tinafw/ui/WebDriverFactoryLocalTest.java import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; import static org.junit.Assume.*; import static org.junit.runners.Parameterized.*; import me.alb_i986.selenium.tinafw.domain.SupportedBrowser; import org.hamcrest.Description; import org.hamcrest.Matcher; import org.hamcrest.TypeSafeMatcher; import org.junit.After; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.openqa.selenium.WebDriver; import java.util.Arrays; package me.alb_i986.selenium.tinafw.ui; @RunWith(Parameterized.class) public class WebDriverFactoryLocalTest { @Parameters(name = "{0}")
public static Iterable<SupportedBrowser> params() {
alb-i986/selenium-tinafw
src/main/java/me/alb_i986/selenium/tinafw/tasks/CompositeWebTask.java
// Path: src/main/java/me/alb_i986/selenium/tinafw/ui/WebPage.java // public interface WebPage { // // /** // * @see Config#getBaseUrl() // */ // public final static String BASE_URL = Config.getBaseUrl(); // // // /** // * @see WebDriver#getTitle() // */ // public String getTitle(); // // /** // * @see WebDriver#getCurrentUrl() // */ // public String getCurrentUrl(); // // }
import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.List; import me.alb_i986.selenium.tinafw.ui.WebPage;
package me.alb_i986.selenium.tinafw.tasks; /** * A WebTask made up of many supposedly small (sub-)tasks, * which in turn may be CompositeWebTask's too. * <p> * CompositeWebTask allows you to build trees of WebTask's. * The idea is to have many atomic WebTask's (the leaves of the tree) * focused on a very small user interaction. * And then you start build up tasks by <i>composition</i>. * <p> * <i>With CompositeWebTask you may even get rid of page objects (!)</i>, * and have WebTask's talk directly to PageComponent's. * <p> * Exploiting the * <a href="http://en.wikipedia.org/wiki/Composite_pattern"> * Composite design pattern</a>. */ public class CompositeWebTask extends BaseWebTask implements Iterable<WebTask> { private List<WebTask> subtasks = new ArrayList<>(); /** * @see #CompositeWebTask(List) */ public CompositeWebTask(WebTask... subtasks) { this(Arrays.asList(subtasks)); } /** * Set the given list as the list of components of this composite. * Replace any null subtask with a {@link WebTasks#nullTask()}. */ public CompositeWebTask(List<WebTask> subtasks) { super(); Collections.replaceAll(subtasks, null, WebTasks.nullTask()); this.subtasks.addAll(subtasks); } /** * Runs each subtask in order, and finally return the * page that the last task was visiting. * Each subtask will run with the same user as the composite. * * @throws IllegalStateException if the user set in this composite is null */ @Override
// Path: src/main/java/me/alb_i986/selenium/tinafw/ui/WebPage.java // public interface WebPage { // // /** // * @see Config#getBaseUrl() // */ // public final static String BASE_URL = Config.getBaseUrl(); // // // /** // * @see WebDriver#getTitle() // */ // public String getTitle(); // // /** // * @see WebDriver#getCurrentUrl() // */ // public String getCurrentUrl(); // // } // Path: src/main/java/me/alb_i986/selenium/tinafw/tasks/CompositeWebTask.java import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.List; import me.alb_i986.selenium.tinafw.ui.WebPage; package me.alb_i986.selenium.tinafw.tasks; /** * A WebTask made up of many supposedly small (sub-)tasks, * which in turn may be CompositeWebTask's too. * <p> * CompositeWebTask allows you to build trees of WebTask's. * The idea is to have many atomic WebTask's (the leaves of the tree) * focused on a very small user interaction. * And then you start build up tasks by <i>composition</i>. * <p> * <i>With CompositeWebTask you may even get rid of page objects (!)</i>, * and have WebTask's talk directly to PageComponent's. * <p> * Exploiting the * <a href="http://en.wikipedia.org/wiki/Composite_pattern"> * Composite design pattern</a>. */ public class CompositeWebTask extends BaseWebTask implements Iterable<WebTask> { private List<WebTask> subtasks = new ArrayList<>(); /** * @see #CompositeWebTask(List) */ public CompositeWebTask(WebTask... subtasks) { this(Arrays.asList(subtasks)); } /** * Set the given list as the list of components of this composite. * Replace any null subtask with a {@link WebTasks#nullTask()}. */ public CompositeWebTask(List<WebTask> subtasks) { super(); Collections.replaceAll(subtasks, null, WebTasks.nullTask()); this.subtasks.addAll(subtasks); } /** * Runs each subtask in order, and finally return the * page that the last task was visiting. * Each subtask will run with the same user as the composite. * * @throws IllegalStateException if the user set in this composite is null */ @Override
public WebPage run(WebPage initialPage) {
alb-i986/selenium-tinafw
src/test/java/me/alb_i986/selenium/tinafw/domain/WebUserTest.java
// Path: src/main/java/me/alb_i986/selenium/tinafw/tasks/WebTask.java // public interface WebTask { // // /** // * Perform this task as the user {@link #getUser()}. // * Precondition: the user must have already been set // * (see {@link #setUser(WebUser)}). // * // * @param initialPage the page it is displayed before this task starts // * @return the last page that is displayed after this task finishes // */ // public WebPage run(WebPage initialPage); // // /** // * Builds an {@link OrWebTask} made up of (in order) // * this task and the given alternative task. // * This method can be "recursively" chained in order to define // * a multi-member OR, e.g.: // * <pre> // * {@code // * new MyTask() // * .or(new AlternativeTask1()) // * .or(new AlternativeTask2()) // * .or(new AlternativeTask3()) // * ; // * } // * </pre> // * // * @param alternativeTask the task to run if this task fails // * @return an {@link OrWebTask} made up of (in order) // * this task and the alternative // */ // default public OrWebTask or(WebTask alternativeTask) { // return new OrWebTask(this, alternativeTask); // } // // /** // * @param user the user this task will run as. // * @return this // */ // public WebTask setUser(WebUser user); // // /** // * @return the user that this task runs as // */ // public WebUser getUser(); // // } // // Path: src/main/java/me/alb_i986/selenium/tinafw/ui/WebPage.java // public interface WebPage { // // /** // * @see Config#getBaseUrl() // */ // public final static String BASE_URL = Config.getBaseUrl(); // // // /** // * @see WebDriver#getTitle() // */ // public String getTitle(); // // /** // * @see WebDriver#getCurrentUrl() // */ // public String getCurrentUrl(); // // }
import static org.junit.Assert.*; import static org.mockito.BDDMockito.*; import me.alb_i986.selenium.tinafw.tasks.WebTask; import me.alb_i986.selenium.tinafw.ui.WebPage; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import org.openqa.selenium.WebDriver;
package me.alb_i986.selenium.tinafw.domain; @RunWith(MockitoJUnitRunner.class) public class WebUserTest {
// Path: src/main/java/me/alb_i986/selenium/tinafw/tasks/WebTask.java // public interface WebTask { // // /** // * Perform this task as the user {@link #getUser()}. // * Precondition: the user must have already been set // * (see {@link #setUser(WebUser)}). // * // * @param initialPage the page it is displayed before this task starts // * @return the last page that is displayed after this task finishes // */ // public WebPage run(WebPage initialPage); // // /** // * Builds an {@link OrWebTask} made up of (in order) // * this task and the given alternative task. // * This method can be "recursively" chained in order to define // * a multi-member OR, e.g.: // * <pre> // * {@code // * new MyTask() // * .or(new AlternativeTask1()) // * .or(new AlternativeTask2()) // * .or(new AlternativeTask3()) // * ; // * } // * </pre> // * // * @param alternativeTask the task to run if this task fails // * @return an {@link OrWebTask} made up of (in order) // * this task and the alternative // */ // default public OrWebTask or(WebTask alternativeTask) { // return new OrWebTask(this, alternativeTask); // } // // /** // * @param user the user this task will run as. // * @return this // */ // public WebTask setUser(WebUser user); // // /** // * @return the user that this task runs as // */ // public WebUser getUser(); // // } // // Path: src/main/java/me/alb_i986/selenium/tinafw/ui/WebPage.java // public interface WebPage { // // /** // * @see Config#getBaseUrl() // */ // public final static String BASE_URL = Config.getBaseUrl(); // // // /** // * @see WebDriver#getTitle() // */ // public String getTitle(); // // /** // * @see WebDriver#getCurrentUrl() // */ // public String getCurrentUrl(); // // } // Path: src/test/java/me/alb_i986/selenium/tinafw/domain/WebUserTest.java import static org.junit.Assert.*; import static org.mockito.BDDMockito.*; import me.alb_i986.selenium.tinafw.tasks.WebTask; import me.alb_i986.selenium.tinafw.ui.WebPage; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import org.openqa.selenium.WebDriver; package me.alb_i986.selenium.tinafw.domain; @RunWith(MockitoJUnitRunner.class) public class WebUserTest {
@Mock private WebPage stubPage;
alb-i986/selenium-tinafw
src/test/java/me/alb_i986/selenium/tinafw/domain/WebUserTest.java
// Path: src/main/java/me/alb_i986/selenium/tinafw/tasks/WebTask.java // public interface WebTask { // // /** // * Perform this task as the user {@link #getUser()}. // * Precondition: the user must have already been set // * (see {@link #setUser(WebUser)}). // * // * @param initialPage the page it is displayed before this task starts // * @return the last page that is displayed after this task finishes // */ // public WebPage run(WebPage initialPage); // // /** // * Builds an {@link OrWebTask} made up of (in order) // * this task and the given alternative task. // * This method can be "recursively" chained in order to define // * a multi-member OR, e.g.: // * <pre> // * {@code // * new MyTask() // * .or(new AlternativeTask1()) // * .or(new AlternativeTask2()) // * .or(new AlternativeTask3()) // * ; // * } // * </pre> // * // * @param alternativeTask the task to run if this task fails // * @return an {@link OrWebTask} made up of (in order) // * this task and the alternative // */ // default public OrWebTask or(WebTask alternativeTask) { // return new OrWebTask(this, alternativeTask); // } // // /** // * @param user the user this task will run as. // * @return this // */ // public WebTask setUser(WebUser user); // // /** // * @return the user that this task runs as // */ // public WebUser getUser(); // // } // // Path: src/main/java/me/alb_i986/selenium/tinafw/ui/WebPage.java // public interface WebPage { // // /** // * @see Config#getBaseUrl() // */ // public final static String BASE_URL = Config.getBaseUrl(); // // // /** // * @see WebDriver#getTitle() // */ // public String getTitle(); // // /** // * @see WebDriver#getCurrentUrl() // */ // public String getCurrentUrl(); // // }
import static org.junit.Assert.*; import static org.mockito.BDDMockito.*; import me.alb_i986.selenium.tinafw.tasks.WebTask; import me.alb_i986.selenium.tinafw.ui.WebPage; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import org.openqa.selenium.WebDriver;
package me.alb_i986.selenium.tinafw.domain; @RunWith(MockitoJUnitRunner.class) public class WebUserTest { @Mock private WebPage stubPage; @Mock private WebDriver mockedDriver;
// Path: src/main/java/me/alb_i986/selenium/tinafw/tasks/WebTask.java // public interface WebTask { // // /** // * Perform this task as the user {@link #getUser()}. // * Precondition: the user must have already been set // * (see {@link #setUser(WebUser)}). // * // * @param initialPage the page it is displayed before this task starts // * @return the last page that is displayed after this task finishes // */ // public WebPage run(WebPage initialPage); // // /** // * Builds an {@link OrWebTask} made up of (in order) // * this task and the given alternative task. // * This method can be "recursively" chained in order to define // * a multi-member OR, e.g.: // * <pre> // * {@code // * new MyTask() // * .or(new AlternativeTask1()) // * .or(new AlternativeTask2()) // * .or(new AlternativeTask3()) // * ; // * } // * </pre> // * // * @param alternativeTask the task to run if this task fails // * @return an {@link OrWebTask} made up of (in order) // * this task and the alternative // */ // default public OrWebTask or(WebTask alternativeTask) { // return new OrWebTask(this, alternativeTask); // } // // /** // * @param user the user this task will run as. // * @return this // */ // public WebTask setUser(WebUser user); // // /** // * @return the user that this task runs as // */ // public WebUser getUser(); // // } // // Path: src/main/java/me/alb_i986/selenium/tinafw/ui/WebPage.java // public interface WebPage { // // /** // * @see Config#getBaseUrl() // */ // public final static String BASE_URL = Config.getBaseUrl(); // // // /** // * @see WebDriver#getTitle() // */ // public String getTitle(); // // /** // * @see WebDriver#getCurrentUrl() // */ // public String getCurrentUrl(); // // } // Path: src/test/java/me/alb_i986/selenium/tinafw/domain/WebUserTest.java import static org.junit.Assert.*; import static org.mockito.BDDMockito.*; import me.alb_i986.selenium.tinafw.tasks.WebTask; import me.alb_i986.selenium.tinafw.ui.WebPage; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import org.openqa.selenium.WebDriver; package me.alb_i986.selenium.tinafw.domain; @RunWith(MockitoJUnitRunner.class) public class WebUserTest { @Mock private WebPage stubPage; @Mock private WebDriver mockedDriver;
@Mock private WebTask taskStub;
alb-i986/selenium-tinafw
src/main/java/me/alb_i986/selenium/tinafw/domain/WebUser.java
// Path: src/main/java/me/alb_i986/selenium/tinafw/tasks/CompositeWebTask.java // public class CompositeWebTask extends BaseWebTask implements Iterable<WebTask> { // // private List<WebTask> subtasks = new ArrayList<>(); // // /** // * @see #CompositeWebTask(List) // */ // public CompositeWebTask(WebTask... subtasks) { // this(Arrays.asList(subtasks)); // } // // /** // * Set the given list as the list of components of this composite. // * Replace any null subtask with a {@link WebTasks#nullTask()}. // */ // public CompositeWebTask(List<WebTask> subtasks) { // super(); // Collections.replaceAll(subtasks, null, WebTasks.nullTask()); // this.subtasks.addAll(subtasks); // } // // /** // * Runs each subtask in order, and finally return the // * page that the last task was visiting. // * Each subtask will run with the same user as the composite. // * // * @throws IllegalStateException if the user set in this composite is null // */ // @Override // public WebPage run(WebPage initialPage) { // if(getUser() == null) // throw new IllegalStateException("the user set is null"); // WebPage currentPage = initialPage; // for(WebTask task : this) { // logger.info("BEGIN subtask " + task.getClass().getSimpleName()); // // before running the subtask, set the user // task.setUser(getUser()); // currentPage = task.run(currentPage); // logger.info("END subtask " + task.getClass().getSimpleName()); // } // return currentPage; // } // // /** // * The iterator for iterating over the subtasks // * this composite is made up of. // * <p> // * Backed by {@link List#iterator()}. // */ // @Override // public Iterator<WebTask> iterator() { // return subtasks.iterator(); // } // // /** // * Append the given subtasks to the list of components. // * @param subtasks // * @return this // */ // public CompositeWebTask append(WebTask... subtasks) { // this.subtasks.addAll(Arrays.asList(subtasks)); // return this; // } // // } // // Path: src/main/java/me/alb_i986/selenium/tinafw/tasks/WebTask.java // public interface WebTask { // // /** // * Perform this task as the user {@link #getUser()}. // * Precondition: the user must have already been set // * (see {@link #setUser(WebUser)}). // * // * @param initialPage the page it is displayed before this task starts // * @return the last page that is displayed after this task finishes // */ // public WebPage run(WebPage initialPage); // // /** // * Builds an {@link OrWebTask} made up of (in order) // * this task and the given alternative task. // * This method can be "recursively" chained in order to define // * a multi-member OR, e.g.: // * <pre> // * {@code // * new MyTask() // * .or(new AlternativeTask1()) // * .or(new AlternativeTask2()) // * .or(new AlternativeTask3()) // * ; // * } // * </pre> // * // * @param alternativeTask the task to run if this task fails // * @return an {@link OrWebTask} made up of (in order) // * this task and the alternative // */ // default public OrWebTask or(WebTask alternativeTask) { // return new OrWebTask(this, alternativeTask); // } // // /** // * @param user the user this task will run as. // * @return this // */ // public WebTask setUser(WebUser user); // // /** // * @return the user that this task runs as // */ // public WebUser getUser(); // // } // // Path: src/main/java/me/alb_i986/selenium/tinafw/ui/WebPage.java // public interface WebPage { // // /** // * @see Config#getBaseUrl() // */ // public final static String BASE_URL = Config.getBaseUrl(); // // // /** // * @see WebDriver#getTitle() // */ // public String getTitle(); // // /** // * @see WebDriver#getCurrentUrl() // */ // public String getCurrentUrl(); // // }
import com.google.inject.Inject; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import me.alb_i986.selenium.tinafw.tasks.CompositeWebTask; import me.alb_i986.selenium.tinafw.tasks.WebTask; import me.alb_i986.selenium.tinafw.ui.WebPage;
*/ public void closeBrowser() { browser.close(); currentPage = null; } /** * @param relativeUrl a relative URL (relative to {@link WebPage#BASE_URL}) * @see Browser#browseTo(String) */ @SuppressWarnings("unchecked") public T browseTo(String relativeUrl) { browser.browseTo(relativeUrl); return (T) this; } /** * Run the given task (or task<i>s</i>, * if it is a {@link CompositeWebTask}), * starting from the known current page * (which is part of the state of this object). * Finally update the current page with the one * the given task visited last. * * @param task * @return this * * @see WebTask#run(WebPage) */ @SuppressWarnings("unchecked")
// Path: src/main/java/me/alb_i986/selenium/tinafw/tasks/CompositeWebTask.java // public class CompositeWebTask extends BaseWebTask implements Iterable<WebTask> { // // private List<WebTask> subtasks = new ArrayList<>(); // // /** // * @see #CompositeWebTask(List) // */ // public CompositeWebTask(WebTask... subtasks) { // this(Arrays.asList(subtasks)); // } // // /** // * Set the given list as the list of components of this composite. // * Replace any null subtask with a {@link WebTasks#nullTask()}. // */ // public CompositeWebTask(List<WebTask> subtasks) { // super(); // Collections.replaceAll(subtasks, null, WebTasks.nullTask()); // this.subtasks.addAll(subtasks); // } // // /** // * Runs each subtask in order, and finally return the // * page that the last task was visiting. // * Each subtask will run with the same user as the composite. // * // * @throws IllegalStateException if the user set in this composite is null // */ // @Override // public WebPage run(WebPage initialPage) { // if(getUser() == null) // throw new IllegalStateException("the user set is null"); // WebPage currentPage = initialPage; // for(WebTask task : this) { // logger.info("BEGIN subtask " + task.getClass().getSimpleName()); // // before running the subtask, set the user // task.setUser(getUser()); // currentPage = task.run(currentPage); // logger.info("END subtask " + task.getClass().getSimpleName()); // } // return currentPage; // } // // /** // * The iterator for iterating over the subtasks // * this composite is made up of. // * <p> // * Backed by {@link List#iterator()}. // */ // @Override // public Iterator<WebTask> iterator() { // return subtasks.iterator(); // } // // /** // * Append the given subtasks to the list of components. // * @param subtasks // * @return this // */ // public CompositeWebTask append(WebTask... subtasks) { // this.subtasks.addAll(Arrays.asList(subtasks)); // return this; // } // // } // // Path: src/main/java/me/alb_i986/selenium/tinafw/tasks/WebTask.java // public interface WebTask { // // /** // * Perform this task as the user {@link #getUser()}. // * Precondition: the user must have already been set // * (see {@link #setUser(WebUser)}). // * // * @param initialPage the page it is displayed before this task starts // * @return the last page that is displayed after this task finishes // */ // public WebPage run(WebPage initialPage); // // /** // * Builds an {@link OrWebTask} made up of (in order) // * this task and the given alternative task. // * This method can be "recursively" chained in order to define // * a multi-member OR, e.g.: // * <pre> // * {@code // * new MyTask() // * .or(new AlternativeTask1()) // * .or(new AlternativeTask2()) // * .or(new AlternativeTask3()) // * ; // * } // * </pre> // * // * @param alternativeTask the task to run if this task fails // * @return an {@link OrWebTask} made up of (in order) // * this task and the alternative // */ // default public OrWebTask or(WebTask alternativeTask) { // return new OrWebTask(this, alternativeTask); // } // // /** // * @param user the user this task will run as. // * @return this // */ // public WebTask setUser(WebUser user); // // /** // * @return the user that this task runs as // */ // public WebUser getUser(); // // } // // Path: src/main/java/me/alb_i986/selenium/tinafw/ui/WebPage.java // public interface WebPage { // // /** // * @see Config#getBaseUrl() // */ // public final static String BASE_URL = Config.getBaseUrl(); // // // /** // * @see WebDriver#getTitle() // */ // public String getTitle(); // // /** // * @see WebDriver#getCurrentUrl() // */ // public String getCurrentUrl(); // // } // Path: src/main/java/me/alb_i986/selenium/tinafw/domain/WebUser.java import com.google.inject.Inject; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import me.alb_i986.selenium.tinafw.tasks.CompositeWebTask; import me.alb_i986.selenium.tinafw.tasks.WebTask; import me.alb_i986.selenium.tinafw.ui.WebPage; */ public void closeBrowser() { browser.close(); currentPage = null; } /** * @param relativeUrl a relative URL (relative to {@link WebPage#BASE_URL}) * @see Browser#browseTo(String) */ @SuppressWarnings("unchecked") public T browseTo(String relativeUrl) { browser.browseTo(relativeUrl); return (T) this; } /** * Run the given task (or task<i>s</i>, * if it is a {@link CompositeWebTask}), * starting from the known current page * (which is part of the state of this object). * Finally update the current page with the one * the given task visited last. * * @param task * @return this * * @see WebTask#run(WebPage) */ @SuppressWarnings("unchecked")
public T doTask(WebTask task) {
alb-i986/selenium-tinafw
src/main/java/me/alb_i986/selenium/tinafw/domain/WebUser.java
// Path: src/main/java/me/alb_i986/selenium/tinafw/tasks/CompositeWebTask.java // public class CompositeWebTask extends BaseWebTask implements Iterable<WebTask> { // // private List<WebTask> subtasks = new ArrayList<>(); // // /** // * @see #CompositeWebTask(List) // */ // public CompositeWebTask(WebTask... subtasks) { // this(Arrays.asList(subtasks)); // } // // /** // * Set the given list as the list of components of this composite. // * Replace any null subtask with a {@link WebTasks#nullTask()}. // */ // public CompositeWebTask(List<WebTask> subtasks) { // super(); // Collections.replaceAll(subtasks, null, WebTasks.nullTask()); // this.subtasks.addAll(subtasks); // } // // /** // * Runs each subtask in order, and finally return the // * page that the last task was visiting. // * Each subtask will run with the same user as the composite. // * // * @throws IllegalStateException if the user set in this composite is null // */ // @Override // public WebPage run(WebPage initialPage) { // if(getUser() == null) // throw new IllegalStateException("the user set is null"); // WebPage currentPage = initialPage; // for(WebTask task : this) { // logger.info("BEGIN subtask " + task.getClass().getSimpleName()); // // before running the subtask, set the user // task.setUser(getUser()); // currentPage = task.run(currentPage); // logger.info("END subtask " + task.getClass().getSimpleName()); // } // return currentPage; // } // // /** // * The iterator for iterating over the subtasks // * this composite is made up of. // * <p> // * Backed by {@link List#iterator()}. // */ // @Override // public Iterator<WebTask> iterator() { // return subtasks.iterator(); // } // // /** // * Append the given subtasks to the list of components. // * @param subtasks // * @return this // */ // public CompositeWebTask append(WebTask... subtasks) { // this.subtasks.addAll(Arrays.asList(subtasks)); // return this; // } // // } // // Path: src/main/java/me/alb_i986/selenium/tinafw/tasks/WebTask.java // public interface WebTask { // // /** // * Perform this task as the user {@link #getUser()}. // * Precondition: the user must have already been set // * (see {@link #setUser(WebUser)}). // * // * @param initialPage the page it is displayed before this task starts // * @return the last page that is displayed after this task finishes // */ // public WebPage run(WebPage initialPage); // // /** // * Builds an {@link OrWebTask} made up of (in order) // * this task and the given alternative task. // * This method can be "recursively" chained in order to define // * a multi-member OR, e.g.: // * <pre> // * {@code // * new MyTask() // * .or(new AlternativeTask1()) // * .or(new AlternativeTask2()) // * .or(new AlternativeTask3()) // * ; // * } // * </pre> // * // * @param alternativeTask the task to run if this task fails // * @return an {@link OrWebTask} made up of (in order) // * this task and the alternative // */ // default public OrWebTask or(WebTask alternativeTask) { // return new OrWebTask(this, alternativeTask); // } // // /** // * @param user the user this task will run as. // * @return this // */ // public WebTask setUser(WebUser user); // // /** // * @return the user that this task runs as // */ // public WebUser getUser(); // // } // // Path: src/main/java/me/alb_i986/selenium/tinafw/ui/WebPage.java // public interface WebPage { // // /** // * @see Config#getBaseUrl() // */ // public final static String BASE_URL = Config.getBaseUrl(); // // // /** // * @see WebDriver#getTitle() // */ // public String getTitle(); // // /** // * @see WebDriver#getCurrentUrl() // */ // public String getCurrentUrl(); // // }
import com.google.inject.Inject; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import me.alb_i986.selenium.tinafw.tasks.CompositeWebTask; import me.alb_i986.selenium.tinafw.tasks.WebTask; import me.alb_i986.selenium.tinafw.ui.WebPage;
* (which is part of the state of this object). * Finally update the current page with the one * the given task visited last. * * @param task * @return this * * @see WebTask#run(WebPage) */ @SuppressWarnings("unchecked") public T doTask(WebTask task) { task.setUser(this); this.currentPage = task.run(currentPage); return (T) this; } /** * Instantiate a {@link CompositeWebTask} made up of all * of the given tasks, and run it. * <p> * Convenience method for running multiple tasks at once * without wrapping them around a {@link CompositeWebTask} * by hand. * * @param tasks * @return this * * @see #doTask(WebTask) */ public T doTasks(WebTask... tasks) {
// Path: src/main/java/me/alb_i986/selenium/tinafw/tasks/CompositeWebTask.java // public class CompositeWebTask extends BaseWebTask implements Iterable<WebTask> { // // private List<WebTask> subtasks = new ArrayList<>(); // // /** // * @see #CompositeWebTask(List) // */ // public CompositeWebTask(WebTask... subtasks) { // this(Arrays.asList(subtasks)); // } // // /** // * Set the given list as the list of components of this composite. // * Replace any null subtask with a {@link WebTasks#nullTask()}. // */ // public CompositeWebTask(List<WebTask> subtasks) { // super(); // Collections.replaceAll(subtasks, null, WebTasks.nullTask()); // this.subtasks.addAll(subtasks); // } // // /** // * Runs each subtask in order, and finally return the // * page that the last task was visiting. // * Each subtask will run with the same user as the composite. // * // * @throws IllegalStateException if the user set in this composite is null // */ // @Override // public WebPage run(WebPage initialPage) { // if(getUser() == null) // throw new IllegalStateException("the user set is null"); // WebPage currentPage = initialPage; // for(WebTask task : this) { // logger.info("BEGIN subtask " + task.getClass().getSimpleName()); // // before running the subtask, set the user // task.setUser(getUser()); // currentPage = task.run(currentPage); // logger.info("END subtask " + task.getClass().getSimpleName()); // } // return currentPage; // } // // /** // * The iterator for iterating over the subtasks // * this composite is made up of. // * <p> // * Backed by {@link List#iterator()}. // */ // @Override // public Iterator<WebTask> iterator() { // return subtasks.iterator(); // } // // /** // * Append the given subtasks to the list of components. // * @param subtasks // * @return this // */ // public CompositeWebTask append(WebTask... subtasks) { // this.subtasks.addAll(Arrays.asList(subtasks)); // return this; // } // // } // // Path: src/main/java/me/alb_i986/selenium/tinafw/tasks/WebTask.java // public interface WebTask { // // /** // * Perform this task as the user {@link #getUser()}. // * Precondition: the user must have already been set // * (see {@link #setUser(WebUser)}). // * // * @param initialPage the page it is displayed before this task starts // * @return the last page that is displayed after this task finishes // */ // public WebPage run(WebPage initialPage); // // /** // * Builds an {@link OrWebTask} made up of (in order) // * this task and the given alternative task. // * This method can be "recursively" chained in order to define // * a multi-member OR, e.g.: // * <pre> // * {@code // * new MyTask() // * .or(new AlternativeTask1()) // * .or(new AlternativeTask2()) // * .or(new AlternativeTask3()) // * ; // * } // * </pre> // * // * @param alternativeTask the task to run if this task fails // * @return an {@link OrWebTask} made up of (in order) // * this task and the alternative // */ // default public OrWebTask or(WebTask alternativeTask) { // return new OrWebTask(this, alternativeTask); // } // // /** // * @param user the user this task will run as. // * @return this // */ // public WebTask setUser(WebUser user); // // /** // * @return the user that this task runs as // */ // public WebUser getUser(); // // } // // Path: src/main/java/me/alb_i986/selenium/tinafw/ui/WebPage.java // public interface WebPage { // // /** // * @see Config#getBaseUrl() // */ // public final static String BASE_URL = Config.getBaseUrl(); // // // /** // * @see WebDriver#getTitle() // */ // public String getTitle(); // // /** // * @see WebDriver#getCurrentUrl() // */ // public String getCurrentUrl(); // // } // Path: src/main/java/me/alb_i986/selenium/tinafw/domain/WebUser.java import com.google.inject.Inject; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import me.alb_i986.selenium.tinafw.tasks.CompositeWebTask; import me.alb_i986.selenium.tinafw.tasks.WebTask; import me.alb_i986.selenium.tinafw.ui.WebPage; * (which is part of the state of this object). * Finally update the current page with the one * the given task visited last. * * @param task * @return this * * @see WebTask#run(WebPage) */ @SuppressWarnings("unchecked") public T doTask(WebTask task) { task.setUser(this); this.currentPage = task.run(currentPage); return (T) this; } /** * Instantiate a {@link CompositeWebTask} made up of all * of the given tasks, and run it. * <p> * Convenience method for running multiple tasks at once * without wrapping them around a {@link CompositeWebTask} * by hand. * * @param tasks * @return this * * @see #doTask(WebTask) */ public T doTasks(WebTask... tasks) {
return doTask(new CompositeWebTask(tasks));
alb-i986/selenium-tinafw
src/main/java/me/alb_i986/selenium/tinafw/tasks/MyBrowserIsOpen.java
// Path: src/main/java/me/alb_i986/selenium/tinafw/tasks/BaseWebTask.java // public abstract class BaseWebTask implements WebTask { // // protected static final Logger logger = LogManager.getLogger(WebTask.class); // // protected WebUser user; // // public BaseWebTask() { // } // // @Override // public WebTask setUser(WebUser user) { // if(user == null) // throw new IllegalArgumentException("user is null"); // this.user = user; // return this; // } // // @Override // public WebUser getUser() { // return user; // } // // // /** // * Convenience method for retrieving the underlying {@link Browser} // * associated to the user this task runs as. // * // * @return the underlying {@link Browser} // */ // protected Browser browser() { // if(user == null) // throw new IllegalStateException("User is null"); // return user.getBrowser(); // } // // /** // * Convenience method for retrieving the underlying {@link WebDriver} // * associated to the user this task runs as. // * // * @return the underlying {@link WebDriver} // */ // protected WebDriver driver() { // if(browser() == null) // throw new IllegalStateException("Browser is null"); // return browser().getWebDriver(); // } // // } // // Path: src/main/java/me/alb_i986/selenium/tinafw/ui/WebPage.java // public interface WebPage { // // /** // * @see Config#getBaseUrl() // */ // public final static String BASE_URL = Config.getBaseUrl(); // // // /** // * @see WebDriver#getTitle() // */ // public String getTitle(); // // /** // * @see WebDriver#getCurrentUrl() // */ // public String getCurrentUrl(); // // }
import me.alb_i986.selenium.tinafw.tasks.BaseWebTask; import me.alb_i986.selenium.tinafw.ui.WebPage;
package me.alb_i986.selenium.tinafw.tasks; /** * Task that opens the browser. */ public class MyBrowserIsOpen extends BaseWebTask { /** * Open the browser. * * @param noPage this param won't be considered: may be null * * @throws IllegalStateException if user has not been set */ @Override
// Path: src/main/java/me/alb_i986/selenium/tinafw/tasks/BaseWebTask.java // public abstract class BaseWebTask implements WebTask { // // protected static final Logger logger = LogManager.getLogger(WebTask.class); // // protected WebUser user; // // public BaseWebTask() { // } // // @Override // public WebTask setUser(WebUser user) { // if(user == null) // throw new IllegalArgumentException("user is null"); // this.user = user; // return this; // } // // @Override // public WebUser getUser() { // return user; // } // // // /** // * Convenience method for retrieving the underlying {@link Browser} // * associated to the user this task runs as. // * // * @return the underlying {@link Browser} // */ // protected Browser browser() { // if(user == null) // throw new IllegalStateException("User is null"); // return user.getBrowser(); // } // // /** // * Convenience method for retrieving the underlying {@link WebDriver} // * associated to the user this task runs as. // * // * @return the underlying {@link WebDriver} // */ // protected WebDriver driver() { // if(browser() == null) // throw new IllegalStateException("Browser is null"); // return browser().getWebDriver(); // } // // } // // Path: src/main/java/me/alb_i986/selenium/tinafw/ui/WebPage.java // public interface WebPage { // // /** // * @see Config#getBaseUrl() // */ // public final static String BASE_URL = Config.getBaseUrl(); // // // /** // * @see WebDriver#getTitle() // */ // public String getTitle(); // // /** // * @see WebDriver#getCurrentUrl() // */ // public String getCurrentUrl(); // // } // Path: src/main/java/me/alb_i986/selenium/tinafw/tasks/MyBrowserIsOpen.java import me.alb_i986.selenium.tinafw.tasks.BaseWebTask; import me.alb_i986.selenium.tinafw.ui.WebPage; package me.alb_i986.selenium.tinafw.tasks; /** * Task that opens the browser. */ public class MyBrowserIsOpen extends BaseWebTask { /** * Open the browser. * * @param noPage this param won't be considered: may be null * * @throws IllegalStateException if user has not been set */ @Override
public WebPage run(WebPage noPage) {
alb-i986/selenium-tinafw
src/main/java/me/alb_i986/selenium/tinafw/sample/ui/SearchResult.java
// Path: src/main/java/me/alb_i986/selenium/tinafw/ui/BaseWebPage.java // public abstract class BaseWebPage implements WebPage { // // protected static final Logger logger = LogManager.getLogger(WebPage.class); // // protected WebDriver driver; // protected WebPage previousPage; // // /** // * Calls {@link PageFactory#initElements(WebDriver, Object)} // * and {@link #waitUntilIsLoaded()}. // * // * @param driver // * @param previous // */ // public BaseWebPage(WebDriver driver, WebPage previous) { // this.driver = driver; // this.previousPage = previous; // PageFactory.initElements(driver, this); // logger.info("Loading page " + getClass().getSimpleName()); // waitUntilIsLoaded(); // } // // // /** // * @see WebDriver#getTitle() // */ // @Override // public String getTitle() { // return driver.getTitle(); // } // // /** // * @see WebDriver#getCurrentUrl() // */ // @Override // public String getCurrentUrl() { // return driver.getCurrentUrl(); // } // // /** // * @param locator // * @return {@link WebElement} // * // * @see WebDriver#findElement(By) // */ // protected WebElement getElement(By locator) { // return driver.findElement(locator); // } // // /** // * @param locator // * @return list of {@link WebElement}s // * // * @see WebDriver#findElements(By) // */ // protected List<WebElement> getElements(By locator) { // return driver.findElements(locator); // } // // /** // * Dumb wait until the HTML body element is visible. // * Actually this method should be abstract, // * but it isn't just for convenience. // * It is highly recommended to override it. // * Or you may just override {@link #getIdentifyingLocator()}. // */ // protected void waitUntilIsLoaded() { // PageHelper.waitUntil( // ExpectedConditions.visibilityOfElementLocated(getIdentifyingLocator()), // driver // ); // } // // protected By getIdentifyingLocator() { // return By.tagName("body"); // } // // } // // Path: src/main/java/me/alb_i986/selenium/tinafw/ui/WebPage.java // public interface WebPage { // // /** // * @see Config#getBaseUrl() // */ // public final static String BASE_URL = Config.getBaseUrl(); // // // /** // * @see WebDriver#getTitle() // */ // public String getTitle(); // // /** // * @see WebDriver#getCurrentUrl() // */ // public String getCurrentUrl(); // // }
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import me.alb_i986.selenium.tinafw.ui.BaseWebPage; import me.alb_i986.selenium.tinafw.ui.WebPage;
package me.alb_i986.selenium.tinafw.sample.ui; /** * Models a single box in the {@link SearchResultsPage}, * representing a single search result, * corresponding to an about.me profile. * */ public class SearchResult extends BaseWebPage { private static final By NAME_LOCATOR = By.cssSelector(".thumb_description a"); private static final By COMPLIMENT_LOCATOR = By.cssSelector(".action.compliment"); private WebElement root;
// Path: src/main/java/me/alb_i986/selenium/tinafw/ui/BaseWebPage.java // public abstract class BaseWebPage implements WebPage { // // protected static final Logger logger = LogManager.getLogger(WebPage.class); // // protected WebDriver driver; // protected WebPage previousPage; // // /** // * Calls {@link PageFactory#initElements(WebDriver, Object)} // * and {@link #waitUntilIsLoaded()}. // * // * @param driver // * @param previous // */ // public BaseWebPage(WebDriver driver, WebPage previous) { // this.driver = driver; // this.previousPage = previous; // PageFactory.initElements(driver, this); // logger.info("Loading page " + getClass().getSimpleName()); // waitUntilIsLoaded(); // } // // // /** // * @see WebDriver#getTitle() // */ // @Override // public String getTitle() { // return driver.getTitle(); // } // // /** // * @see WebDriver#getCurrentUrl() // */ // @Override // public String getCurrentUrl() { // return driver.getCurrentUrl(); // } // // /** // * @param locator // * @return {@link WebElement} // * // * @see WebDriver#findElement(By) // */ // protected WebElement getElement(By locator) { // return driver.findElement(locator); // } // // /** // * @param locator // * @return list of {@link WebElement}s // * // * @see WebDriver#findElements(By) // */ // protected List<WebElement> getElements(By locator) { // return driver.findElements(locator); // } // // /** // * Dumb wait until the HTML body element is visible. // * Actually this method should be abstract, // * but it isn't just for convenience. // * It is highly recommended to override it. // * Or you may just override {@link #getIdentifyingLocator()}. // */ // protected void waitUntilIsLoaded() { // PageHelper.waitUntil( // ExpectedConditions.visibilityOfElementLocated(getIdentifyingLocator()), // driver // ); // } // // protected By getIdentifyingLocator() { // return By.tagName("body"); // } // // } // // Path: src/main/java/me/alb_i986/selenium/tinafw/ui/WebPage.java // public interface WebPage { // // /** // * @see Config#getBaseUrl() // */ // public final static String BASE_URL = Config.getBaseUrl(); // // // /** // * @see WebDriver#getTitle() // */ // public String getTitle(); // // /** // * @see WebDriver#getCurrentUrl() // */ // public String getCurrentUrl(); // // } // Path: src/main/java/me/alb_i986/selenium/tinafw/sample/ui/SearchResult.java import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import me.alb_i986.selenium.tinafw.ui.BaseWebPage; import me.alb_i986.selenium.tinafw.ui.WebPage; package me.alb_i986.selenium.tinafw.sample.ui; /** * Models a single box in the {@link SearchResultsPage}, * representing a single search result, * corresponding to an about.me profile. * */ public class SearchResult extends BaseWebPage { private static final By NAME_LOCATOR = By.cssSelector(".thumb_description a"); private static final By COMPLIMENT_LOCATOR = By.cssSelector(".action.compliment"); private WebElement root;
public SearchResult(WebElement root, WebDriver driver, WebPage previous) {
alb-i986/selenium-tinafw
src/test/java/me/alb_i986/selenium/tinafw/tasks/WebTasksTest.java
// Path: src/main/java/me/alb_i986/selenium/tinafw/ui/WebPage.java // public interface WebPage { // // /** // * @see Config#getBaseUrl() // */ // public final static String BASE_URL = Config.getBaseUrl(); // // // /** // * @see WebDriver#getTitle() // */ // public String getTitle(); // // /** // * @see WebDriver#getCurrentUrl() // */ // public String getCurrentUrl(); // // }
import org.junit.Before; import org.junit.Test; import me.alb_i986.selenium.tinafw.ui.WebPage; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import static org.hamcrest.Matchers.*; import static org.junit.Assert.*;
package me.alb_i986.selenium.tinafw.tasks; @RunWith(MockitoJUnitRunner.class) public class WebTasksTest { @Mock
// Path: src/main/java/me/alb_i986/selenium/tinafw/ui/WebPage.java // public interface WebPage { // // /** // * @see Config#getBaseUrl() // */ // public final static String BASE_URL = Config.getBaseUrl(); // // // /** // * @see WebDriver#getTitle() // */ // public String getTitle(); // // /** // * @see WebDriver#getCurrentUrl() // */ // public String getCurrentUrl(); // // } // Path: src/test/java/me/alb_i986/selenium/tinafw/tasks/WebTasksTest.java import org.junit.Before; import org.junit.Test; import me.alb_i986.selenium.tinafw.ui.WebPage; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; package me.alb_i986.selenium.tinafw.tasks; @RunWith(MockitoJUnitRunner.class) public class WebTasksTest { @Mock
private WebPage stubPage;